Esempio n. 1
0
 protected override void Deregister()
 {
     if (_classRegister != 0)
     {
         HRESULT result = ComAPI.CoRevokeClassObject(_classRegister);
         if (result != ComAPI.S_OK)
         {
             Debug.Print("ClassFactory deregistration failed. Result: {0}", result);
         }
         _classRegister = 0;
     }
 }
Esempio n. 2
0
        public ClassFactoryRegistration(Type type, CLSID clsId)
        {
            ClassFactory factory  = new ClassFactory(type);
            IntPtr       pFactory = Marshal.GetIUnknownForObject(factory);
            HRESULT      result   = ComAPI.CoRegisterClassObject(ref clsId, pFactory,
                                                                 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, out _classRegister);

            if (result != ComAPI.S_OK)
            {
                throw new InvalidOperationException("CoRegisterClassObject failed.");
            }
        }
Esempio n. 3
0
        public SingletonClassFactoryRegistration(object instance, CLSID clsId)
        {
            _instance = instance;
            SingletonClassFactory factory = new SingletonClassFactory(instance);
            IntPtr pFactory = Marshal.GetIUnknownForObject(factory);
            // In versions < 0.29 we registered as REGCLS_SINGLEUSE even though it is not supposed to work for inproc servers.
            // It seems to do no harm to keep the ClassObject around.
            HRESULT result = ComAPI.CoRegisterClassObject(ref clsId, pFactory,
                                                          CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, out _classRegister);

            if (result != ComAPI.S_OK)
            {
                throw new InvalidOperationException("CoRegisterClassObject failed.");
            }
        }