[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

COM Interop Threading/Remoting Issue

COM Interop Threading/Remoting Issue

GP

11/27/2007 8:28:00 PM

I have an application that uses a .NET Remoting singleton object to handle
requests from many clients. The Remoting object is hosted by a Windows
Service. The Remoting object also uses a third-party COM object, which runs
in its own process and which I believe runs apartment threaded. Instances of
this third-party COM object can persist for quite some time and can
potentially be accessed on different threads. Periodically I receive the
following error message when attempting to access a method or property of the
COM object (it could happen on any method/property, there is no consistency):

System.Runtime.InteropServices.InvalidComObjectException: COM object that
has been separated from its underlying RCW cannot be used.

I have not done anything that would have explicitly released the underlying
COM object at this point. I am unable to reproduce the issue at will; it
seems to happen randomly. Here are a few theories that I am currently
working on:

1. Could the problem be due to the fact that multiple threads (and not
always the thread that created it) are accessing the COM object?
2. Could the COM threading model be causing me issues? My Main() method on
the Windows Service is marked with the STAThread attribute, but I know that
the Remoting requests are being handled by the .NET ThreadPool which contains
MTA threads. Do I need an STA thread to handle all interaction with the COM
object?
3. Could .NET Garbage Collection somehow be related (since the error happens
at seemingly random times)?

Any insights that you can provide on this issue would be much appreciated.

Thanks,
GP

Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
COM Interop Threading/Remoting Issue

Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te

Il servizio è completamente GRATUITO!