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
|
Hi there, I am currently experiencing an issue on one of our WCF Applications where it tries to pull out complex data objects from the database. The UnitOfWork context (LightSpeed v4) that the WCF app is using is set to PerRequestScope() and whenever a call is made to a method, it throws in an InvalidOperationException error (see below). I'm currently setting my UnitOfWork as this:
Binding it within Ninject. Wonder what am I doing wrong? Thanks for the help! Cheers, Ann
|
|
|
Are you able to reproduce this easily or is it something you are noticing occasionally? Typically we have seen this occur when the UnitOfWork is being shared between threads since it is not designed to be ThreadSafe. Could that be possible? I imagine it will depend on what your MyPerRequestUnitOfWorkScope is doing to create and dispose of the UnitOfWork.
|
|
|
Unfortunately, no. Tried recreating it in dev environment using the same pattern of requests on my local machine and it still runs successfully. Sorry, I've realized that I did not completely include the MyPerRequestUnitOfWorkScope class. Here it is:
|
|
|
Just to help get a bit more context do you actually have an available HttpContext (e.g. you have set aspNetCompatibilityEnabled in the web.config) or would this be null as is normally the case in WCF? Ordinarily the approach for item storage in WCF would be to use the OperationContext - is there a particular reason for not using that? If you are interested (and on a bit of a tangent to actually debugging the current issue at hand) I can put together a small example of how you might go about this if that would be of use to you.
|
|
|
I just found out that there's a WcfUnitOfWorkScope which I tried to use, but still throws in the InvalidOperationException for DataReader. In this class, it is using the OperationContext:
|
|
|
I am presuming the OperationContext use is wrapped up in the WcfRequestState implementation? Im still wondering if there is some sharing of a single UOW instance going on here as that would certainly appear to be the most likely cause of this issue (and historically this has always been the case). Are you able to duplicate the problem by running a short but reasonable length concurrent load test e.g. ab -n 1000 -c 5 to generate enough likely concurrency? One thing I cant quite tell is how the actual UOW instances are going to be disposed other than by eventually falling out of scope somewhere and being GC'ed down the line - is that being done elsewhere perhaps?
|
|