Best practice for calling an STA Visual Basic 6.0 COM object in a WCF service: Concurrent access

StackOverflow https://stackoverflow.com/questions/9401325

سؤال

I have a WCF service which calls an STA Visual Basic 6.0 COM object. Everything works normally if only one client is using the service, but as soon as concurrent users start to call it, I'm in trouble and getting all kinds of random errors when calling one of the methods of the COM object.

At first I fixed this problem by adding support for the STAOperationBehavior attribute with the help of the article Calling an STA COM Object from a WCF Operation.

Well, it helped a lot and for some time everything seemed to work well, but now I started to get System.AccessViolationException errors on a particular server when more than one user is calling the service.

I've read that this is probably a thread problem, and I should use mutex or instancecontext in my web service.

What is the best practice for making sure that concurrent users can use an STA COM object in a WCF service without any problems?

هل كانت مفيدة؟

المحلول

If the object is not designed to be used simultaneously by multiple users, then you simply cannot allow multiple users to use it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top