Ejemplo n.º 1
0
 public void Dispose()
 {
     this.fDelegatesBound   = false;
     this.InvokeMemberFnPtr = (NativeMethods.CCorRuntimeHost.Type_InvokeMember)null;
     if (IntPtr.Zero != this.DomainTypePtr)
     {
         Marshal.Release(this.DomainTypePtr);
         this.DomainTypePtr = IntPtr.Zero;
     }
     this.GetTypeFnPtr = (NativeMethods.CCorRuntimeHost.AppDomain_GetType)null;
     if (IntPtr.Zero != this.DomainObjectPtr)
     {
         Marshal.Release(this.DomainObjectPtr);
         this.DomainObjectPtr = IntPtr.Zero;
     }
     this.CurrentDomainFnPtr = (NativeMethods.CCorRuntimeHost.Host_CurrentDomain)null;
     if (IntPtr.Zero != this.RuntimeHostPtr)
     {
         Marshal.Release(this.RuntimeHostPtr);
         this.RuntimeHostPtr = IntPtr.Zero;
     }
     this.RuntimeHostInstance = (NativeMethods.ICorRuntimeHost)null;
 }
Ejemplo n.º 2
0
            private void BindDelegatesToManualCOMPInvokeFunctionPointers()
            {
                if (this.fDelegatesBound)
                {
                    return;
                }
                this.RuntimeHostInstance.Start();
                int ofs1 = 21 * IntPtr.Size;
                int ofs2 = 10 * IntPtr.Size;
                int ofs3 = 57 * IntPtr.Size;

                this.RuntimeHostPtr     = Marshal.GetIUnknownForObject((object)this.RuntimeHostInstance);
                this.CurrentDomainFnPtr = (NativeMethods.CCorRuntimeHost.Host_CurrentDomain)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(this.RuntimeHostPtr), ofs1), typeof(NativeMethods.CCorRuntimeHost.Host_CurrentDomain));
                IntPtr domain;
                int    errorCode1 = this.CurrentDomainFnPtr(this.RuntimeHostPtr, out domain);

                if (errorCode1 < 0)
                {
                    Marshal.ThrowExceptionForHR(errorCode1);
                }
                Guid guid       = typeof(_AppDomain).GUID;
                int  errorCode2 = Marshal.QueryInterface(domain, ref guid, out this.DomainObjectPtr);

                if (errorCode2 < 0)
                {
                    Marshal.ThrowExceptionForHR(errorCode2);
                }
                this.GetTypeFnPtr = (NativeMethods.CCorRuntimeHost.AppDomain_GetType)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(this.DomainObjectPtr), ofs2), typeof(NativeMethods.CCorRuntimeHost.AppDomain_GetType));
                int errorCode3 = this.GetTypeFnPtr(this.DomainObjectPtr, out this.DomainTypePtr);

                if (errorCode3 < 0)
                {
                    Marshal.ThrowExceptionForHR(errorCode3);
                }
                this.InvokeMemberFnPtr = (NativeMethods.CCorRuntimeHost.Type_InvokeMember)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(this.DomainTypePtr), ofs3), typeof(NativeMethods.CCorRuntimeHost.Type_InvokeMember));
                this.fDelegatesBound   = true;
            }