public static IntPtr CreateDispatchProxy(IntPtr pOuter, IPseudoDispatch proxy)
 {
     IntPtr zero = IntPtr.Zero;
     IProxyProvider proxyProvider = proxySupport.GetProxyProvider();
     if (proxyProvider == null)
     {
         throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL");
     }
     int errorCode = proxyProvider.CreateDispatchProxyInstance(pOuter, proxy, out zero);
     Marshal.ReleaseComObject(proxyProvider);
     if (errorCode != HR.S_OK)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(System.ServiceModel.SR.GetString("FailedProxyProviderCreation"), errorCode));
     }
     return zero;
 }
        public static IntPtr CreateDispatchProxy(IntPtr pOuter, IPseudoDispatch proxy)
        {
            IntPtr pInner = IntPtr.Zero;
            IProxyProvider proxyProvider = proxySupport.GetProxyProvider();

            if (proxyProvider == null)
            {
                throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL");
            }
            int hr = proxyProvider.CreateDispatchProxyInstance(pOuter, proxy, out pInner);

            Marshal.ReleaseComObject(proxyProvider);

            if (hr != HR.S_OK)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(SR.GetString(SR.FailedProxyProviderCreation), hr));

            return pInner;

        }