次のコードを使用して、Windows Explorer Shell のバンド サイト サービスにアクセスしています。
Guid GUID_TrayBandSiteService = new Guid(0xF60AD0A0, 0xE5E1, 0x45cb, 0xB5, 0x1A, 0xE1, 0x5B, 0x9F, 0x8B, 0x29, 0x34);
Type shellTrayBandSiteService = Type.GetTypeFromCLSID(GUID_TrayBandSiteService, true);
site = Activator.CreateInstance(shellTrayBandSiteService) as IBandSite;
ほとんどの場合、それはうまく機能します。ごくわずかな割合 (1% 未満) で、Activator.CreateInstance の呼び出しで次の例外がスローされます。
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {F60AD0A0-E5E1-45CB-B51A-E15B9F8B2934} failed due to the following error: 80040154.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
エラー コードを調べたところ、サービスが登録されていないようです。コールはしばらくすると正常に機能し、CLSID は によって提供されるため、実際にはそうではないことは確かですexplorer.exe
。
私は困惑しています。Activator.CreateInstance が失敗する原因は何ですか?