tags:

views:

599

answers:

1

We have a scenario where some .NET code is attempting to access the current instance of a COM (actually DCOM) object.

The object being accessed was developed in VB6. A current instance of it is available on the remote system, and appears to be accessed correctly from VB6 code.

Attempting to call Marshal.GetActiveObject, specifying the class name, causes a COMException to be thrown, referencing error 800401E3 (Operation Unavailable).

The same .NET code appears to operate correctly when run on the machine hosting that DCOM component.

Can anyone suggest why this COMException is getting generated?

+1  A: 

Did you try to use the [STAThread] attribute in the dot net client app?

Ron Klein
Since the .NET client app is a WinForms one, it does have an STAThread attribute. However, the call to GetActiveObject is in a DLL, which does not. I have added verification just prior to the GetActiveObject call to ensure that the thread calling the DLL's method is using STA. So far, it appears that no calls have been made to the method from an application with an unsupported threading mode.
Richard J Foster
It seems like you're onto something. We have now confirmed that there is another client which calls into the DLL from an MTA thread.
Richard J Foster
While we are still occasionally encountering the problem, it seems that it is almost certainly thread related. As a result, I am setting this answer as the "correct" one, even though there may still be another scenario which causes the same symptom.
Richard J Foster
I'm glad I helped, even if it's only a direction...
Ron Klein