Desechar ManagementEventWatcher en biblioteca (DLL)
Frecuentes
Visto 738 veces
0
I'm using a ManagementEventWatcher in my C# library which is imported (referenced) into another project. The problem I have is that in my case the ManagementEventWatcher has to be "stopped" and "disposed" before my application is closed. I'm only allowed to modify the library and not the applications which will implement the library.
He intentado lo siguiente:
public class MyClass:IDisposable ...
Y entonces
public void Dispose()
{
_wmiWatcherRemoved.Stop();
_wmiWatcherRemoved.Dispose();
}
But Dispose will never be executed. So the applications get the following exception:
COM object that has been separated from its underlying RCW can not be used
Any ideas? Thank you for your efforts.
1 Respuestas
0
I'm assuming from the wording of your question that applications using your library encounter the exception you describe as they are closing down?
If this is the case, you might try registering a handler for the AppDomain ProcessExit event, in which you would cause Stop()
y Dispose()
to be called on the watcher instance.
Respondido el 05 de Septiembre de 12 a las 12:09
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c# dll com or haz tu propia pregunta.