Exemple #1
0
        /// <include file='doc\SoapClientImport.uex' path='docs/doc[@for="SoapClientImport.ProcessClientTlbEx"]/*' />
        public void ProcessClientTlbEx(
            string progId,
            string virtualRoot,
            string baseUrl,
            string authentication,
            string assemblyName,
            string typeName
            )
        {
            try
            {
                SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                sp.Demand();
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(System.Security.SecurityException))
                {
                    string Error = Resource.FormatString("Soap_SecurityFailure");
                    ComSoapPublishError.Report(Error);
                }
                throw;
            }

            try
            {
                Platform.Assert(Platform.Whistler, "SoapClientImport.ProcessClientTlbEx");
                //if ProgId is an empty string, it means it does not go in the configuration file
                string ClientDir = GetClientPhysicalPath(true);
                if (progId.Length > 0)
                {
                    // write to the client configuration file
                    Uri    baseUri = new Uri(baseUrl);
                    Uri    fullUri = new Uri(baseUri, virtualRoot);
                    string auth    = authentication;
                    if (auth.Length <= 0 && fullUri.Scheme.ToLower(CultureInfo.InvariantCulture) == "https")
                    {
                        auth = "Windows";
                    }

                    SoapClientConfig.Write(
                        ClientDir,
                        fullUri.AbsoluteUri,
                        assemblyName,
                        typeName,
                        progId,
                        auth
                        );
                }
            }
            catch
            {
                string Error = Resource.FormatString("Soap_ClientConfigAddFailure");
                ComSoapPublishError.Report(Error);
                throw;
            }
        }
 public void ProcessClientTlb(string ProgId, string SrcTlbPath, string PhysicalPath, string VRoot, string BaseUrl, string Mode, string Transport, out string AssemblyName, out string TypeName, out string Error)
 {
     AssemblyName = "";
     TypeName     = "";
     Error        = "";
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
         string clientPhysicalPath = GetClientPhysicalPath(true);
         if (!SrcTlbPath.ToLower(CultureInfo.InvariantCulture).EndsWith("mscoree.dll", StringComparison.Ordinal) && (SrcTlbPath.Length > 0))
         {
             AssemblyName = new GenerateMetadata().Generate(SrcTlbPath, clientPhysicalPath);
             if (ProgId.Length > 0)
             {
                 TypeName = this.GetTypeNameFromProgId(clientPhysicalPath + AssemblyName + ".dll", ProgId);
             }
         }
         else if (ProgId.Length > 0)
         {
             string      g    = (string)Registry.ClassesRoot.OpenSubKey(ProgId + @"\CLSID").GetValue("");
             RegistryKey key2 = Registry.ClassesRoot.OpenSubKey(@"CLSID\{" + new Guid(g) + @"}\InprocServer32");
             AssemblyName = (string)key2.GetValue("Assembly");
             int index = AssemblyName.IndexOf(",");
             if (index > 0)
             {
                 AssemblyName = AssemblyName.Substring(0, index);
             }
             TypeName = (string)key2.GetValue("Class");
         }
         if (ProgId.Length > 0)
         {
             Uri baseUri = new Uri(BaseUrl);
             Uri uri2    = new Uri(baseUri, VRoot);
             if (uri2.Scheme.ToLower(CultureInfo.InvariantCulture) == "https")
             {
                 string authentication = "Windows";
                 SoapClientConfig.Write(clientPhysicalPath, uri2.AbsoluteUri, AssemblyName, TypeName, ProgId, authentication);
             }
             else
             {
                 ClientRemotingConfig.Write(clientPhysicalPath, VRoot, BaseUrl, AssemblyName, TypeName, ProgId, Mode, Transport);
             }
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         Error = exception.ToString();
         ComSoapPublishError.Report(Error);
     }
 }
 public void ProcessClientTlbEx(string progId, string virtualRoot, string baseUrl, string authentication, string assemblyName, string typeName)
 {
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
     }
     catch (SecurityException)
     {
         ComSoapPublishError.Report(Resource.FormatString("Soap_SecurityFailure"));
         throw;
     }
     try
     {
         string clientPhysicalPath = GetClientPhysicalPath(true);
         if (progId.Length > 0)
         {
             Uri    baseUri = new Uri(baseUrl);
             Uri    uri2    = new Uri(baseUri, virtualRoot);
             string str2    = authentication;
             if ((str2.Length <= 0) && (uri2.Scheme.ToLower(CultureInfo.InvariantCulture) == "https"))
             {
                 str2 = "Windows";
             }
             SoapClientConfig.Write(clientPhysicalPath, uri2.AbsoluteUri, assemblyName, typeName, progId, str2);
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(Resource.FormatString("Soap_ClientConfigAddFailure"));
         throw;
     }
 }