ManagementEventWatcher
クラスを使用する.netライブラリを構築しました。私のライブラリは使い捨てなので、通常は using ステートメントでラップし、ManagementEventWatcher
クラスはライブラリによって破棄されます。
私の問題は、ライブラリが COM に公開されており、使い捨てパターンを使用しない VB6 で使用されることです。ユーザーが .net アプリケーション内からライブラリで dispose を呼び出さない場合、または VB6 のためにできない場合、クラスはfrom withinManagementEventWatcher
をスローします。InvalidComObjectException
SinkForEventQuery.Cancel
例外をキャプチャできないため、未処理のままになり、良くありません。私が試すことができるいくつかの回避策はありますか?
System.Runtime.InteropServices.InvalidComObjectException was unhandled
Message=COM object that has been separated from its underlying RCW cannot be used.
Source=mscorlib
StackTrace:
at System.StubHelpers.StubHelpers.StubRegisterRCW(Object pThis, IntPtr pThread)
at System.Management.IWbemServices.CancelAsyncCall_(IWbemObjectSink pSink)
at System.Management.SinkForEventQuery.Cancel()
at System.Management.ManagementEventWatcher.Stop()
at System.Management.ManagementEventWatcher.Finalize()
InnerException: