I'm using the following code to access the Windows Explorer Shell's band site service:
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;
Mostly, it works great. A very small percentage of the time (less than 1%), the call to Activator.CreateInstance throws the following exception:
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)
I've looked up the error code, and it appears to indicate that the service isn't registered. I'm pretty sure that's not actually the case since the call will work just fine a few moments later, and the CLSID is provided by explorer.exe
.
I'm stumped. What might cause Activator.CreateInstance to fail, but only rarely?