This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello - I was interested in your implementation of IDispatchMessageInspector to create and dispose of the UnitOfWork on receipt and return of messages. It looks like a good use of the technology, so I copied and modified it to fit my uses. However, it started crashing on the second request, throwing an exception that claimed the UnitOfWork had been disposed. I went back to your sample and repeated the call to GetProducts() (copy-paste the HTML block, then duplicate the call to GetProducts() in BindControls()) and got the same result - the UnitOfWork has been disposed and can't be referenced. Can this be resolved? I have looked into this for an hour or two, and can't see why this is happening. It looks like it gets a new UnitOfWork with every request, but the debugger doesn't think so... Thanks for the help, Dave Newman |
|
|
Oosp - this is in the DTOs sample... |
|
|
my changed sample code: <body> private void BindControls()
|
|
|
Make sure your Service is configured with an InstanceContextMode of per call (I generally mark it up with the ServiceBehaviorAttribute), otherwise the context lifetime for the UnitOfWork behavior will operate in per session mode which means that it will get re-used for the subsequent requests and find itself disposed :)
Jeremy |
|
|
Jeremy - From what I can tell, it is marked up that way. In fact, the DTO sample from your site is marked up that way as well, adn it has the same problem when I try to call teh service a second time. Can you please try the mods I mentioned above to the DTO sample, and tell me what I need to do in order to make the sample work? That would point me in the right direction to get my code to work, as I pretty much copied the DTO sample verbatim, then changed variable names and such. I understand the concept, but it still doesn't work the way I would expect it to. Thanks, Dave |
|
|
Hi Dave, The DTO sample is not actually marked up with the PerCall ServiceBehavior so I believe that is what will be what is causing the error. If I make the modifications you mentioned to the default sample I can certainly reproduce it for that reason :) To fix the issue, add the following attribute to your StoreService class: [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
Jeremy |
|
|
Thanks, Jeremy. I am new to WCF as well as LightSpeed so I didn't get what you were trying to tell me at first. I thought the [UnitOfWorkPerCallBehavior] attribute was essentially the same thign as the PerCallServiceNehavior you are really talking about. I made the change and now everybody's happy, at least for the moment. Thanks again for the assistance. Dave |
|