Inheritance: System.Runtime.Remoting.Proxies.RealProxy, IRemotingTypeInfo
Exemple #1
0
        // Gets the proxy of the specified COM type. If the COM type is
        // already known, a cached proxy will be returned.
        internal static ComInteropProxy CreateProxy(Type t)
        {
            IntPtr          iunknown = __ComObject.CreateIUnknown(t);
            ComInteropProxy proxy;
            ComInteropProxy cachedProxy = FindProxy(iunknown);

            if (cachedProxy != null)
            {
                // check that the COM type of the cached proxy matches
                // the requested type. See 2nd part of bug #520437.
                Type cachedType = cachedProxy.com_object.GetType();
                if (cachedType != t)
                {
                    throw new InvalidCastException(String.Format("Unable to cast object of type '{0}' to type '{1}'.", cachedType, t));
                }
                proxy = cachedProxy;
                Marshal.Release(iunknown);
            }
            else
            {
                proxy = new ComInteropProxy(t);
                proxy.com_object.Initialize(iunknown, proxy);
            }
            return(proxy);
        }
Exemple #2
0
        void CacheProxy()
        {
            // called from unmanaged code after .ctor is invoked
            // we need .ctor to create unmanaged object and thus IUnknown property value
            ComInteropProxy proxy = null;

            FindProxy(com_object.IUnknown, ref proxy);
            if (proxy == null)
            {
                var self = this;
                AddProxy(com_object.IUnknown, ref self);
            }
            else
            {
                System.Threading.Interlocked.Increment(ref ref_count);
            }
        }
        internal static ComInteropProxy GetProxy(IntPtr pItf, Type t)
        {
            Guid   iid_IUnknown = __ComObject.IID_IUnknown;
            IntPtr intPtr;
            int    errorCode = Marshal.QueryInterface(pItf, ref iid_IUnknown, out intPtr);

            Marshal.ThrowExceptionForHR(errorCode);
            ComInteropProxy comInteropProxy = ComInteropProxy.FindProxy(intPtr);

            if (comInteropProxy == null)
            {
                Marshal.Release(pItf);
                return(new ComInteropProxy(intPtr));
            }
            Marshal.Release(pItf);
            Interlocked.Increment(ref comInteropProxy.ref_count);
            return(comInteropProxy);
        }
        internal static ComInteropProxy CreateProxy(Type t)
        {
            ComInteropProxy comInteropProxy = new ComInteropProxy(t);

            comInteropProxy.com_object.Initialize(t);
            ComInteropProxy comInteropProxy2 = ComInteropProxy.FindProxy(comInteropProxy.com_object.IUnknown);

            if (comInteropProxy2 == null)
            {
                return(comInteropProxy);
            }
            Type type = comInteropProxy2.com_object.GetType();

            if (type != t)
            {
                throw new InvalidCastException(string.Format("Unable to cast object of type '{0}' to type '{1}'.", type, t));
            }
            return(comInteropProxy2);
        }
Exemple #5
0
        internal static ComInteropProxy GetProxy(IntPtr pItf, Type t)
        {
            IntPtr ppv;
            Guid   iid = __ComObject.IID_IUnknown;
            int    hr  = Marshal.QueryInterface(pItf, ref iid, out ppv);

            Marshal.ThrowExceptionForHR(hr);
            ComInteropProxy obj = FindProxy(ppv);

            if (obj == null)
            {
                Marshal.Release(ppv);
                return(new ComInteropProxy(ppv));
            }
            else
            {
                Marshal.Release(ppv);
                System.Threading.Interlocked.Increment(ref obj.ref_count);
                return(obj);
            }
        }
Exemple #6
0
		internal __ComObject (IntPtr pItf, ComInteropProxy p)
		{
			proxy = p;
			InitializeApartmentDetails ();
			Guid iid = IID_IUnknown;
			int hr = Marshal.QueryInterface (pItf, ref iid, out iunknown);
			Marshal.ThrowExceptionForHR (hr);
		}
Exemple #7
0
		internal void Initialize (IntPtr pUnk, ComInteropProxy p)
		{
			proxy = p;
			InitializeApartmentDetails ();
			iunknown = pUnk;
		}
Exemple #8
0
 private extern static void AddProxy(IntPtr pItf, ComInteropProxy proxy);
Exemple #9
0
		public static object GetTypedObjectForIUnknown (IntPtr pUnk, Type t)
		{
			ComInteropProxy proxy = new ComInteropProxy (pUnk, t);
			__ComObject co = (__ComObject)proxy.GetTransparentProxy ();
			foreach (Type itf in t.GetInterfaces ()) {
				if ((itf.Attributes & TypeAttributes.Import) == TypeAttributes.Import) {
					if (co.GetInterface (itf) == IntPtr.Zero)
						return null;
				}
			}
			return co;
		}
Exemple #10
0
		private extern static void AddProxy (IntPtr pItf, ComInteropProxy proxy);
Exemple #11
0
		// Gets the proxy of the specified COM type. If the COM type is
		// already known, a cached proxy will be returned.
		internal static ComInteropProxy CreateProxy (Type t)
		{
			ComInteropProxy proxy = new ComInteropProxy (t);
			proxy.com_object.Initialize (t);

			ComInteropProxy cachedProxy = FindProxy (proxy.com_object.IUnknown);
			if (cachedProxy != null) {
				// check that the COM type of the cached proxy matches
				// the requested type. See 2nd part of bug #520437.
				Type cachedType = cachedProxy.com_object.GetType ();
				if (cachedType != t)
					throw new InvalidCastException (String.Format ("Unable to cast object of type '{0}' to type '{1}'.", cachedType, t));
				return cachedProxy;
			}
			return proxy;
		}
Exemple #12
0
 internal extern static void FindProxy(IntPtr pItf, ref ComInteropProxy proxy);
Exemple #13
0
 private static void AddProxy(IntPtr pItf, ComInteropProxy proxy)
 {
     throw new System.NotImplementedException();
 }
		private static void AddProxy (IntPtr pItf, ComInteropProxy proxy)
		{
			throw new System.NotImplementedException();
		}
 private void CacheProxy()
 {
     ComInteropProxy.AddProxy(this.com_object.IUnknown, this);
 }