public void ProcessServerTlb(string ProgId, string SrcTlbPath, string PhysicalPath, string Operation, out string strAssemblyName, out string TypeName, out string Error)
        {
            string name = string.Empty;

            strAssemblyName = string.Empty;
            TypeName        = string.Empty;
            Error           = string.Empty;
            bool flag = false;

            try
            {
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
                if ((Operation != null) && (Operation.ToLower(CultureInfo.InvariantCulture) == "delete"))
                {
                    flag = true;
                }
                if (SrcTlbPath.Length > 0)
                {
                    if (!PhysicalPath.EndsWith("/", StringComparison.Ordinal) && !PhysicalPath.EndsWith(@"\", StringComparison.Ordinal))
                    {
                        PhysicalPath = PhysicalPath + @"\";
                    }
                    string str2 = SrcTlbPath.ToLower(CultureInfo.InvariantCulture);
                    if (str2.EndsWith("mscoree.dll", StringComparison.Ordinal))
                    {
                        Type typeFromProgID = Type.GetTypeFromProgID(ProgId);
                        if (typeFromProgID.FullName == "System.__ComObject")
                        {
                            throw new ServicedComponentException(Resource.FormatString("ServicedComponentException_DependencyNotInGAC"));
                        }
                        TypeName = typeFromProgID.FullName;
                        name     = typeFromProgID.Assembly.GetName().Name;
                    }
                    else if (str2.EndsWith("scrobj.dll", StringComparison.Ordinal))
                    {
                        if (!flag)
                        {
                            throw new ServicedComponentException(Resource.FormatString("ServicedComponentException_WSCNotSupported"));
                        }
                    }
                    else
                    {
                        GenerateMetadata metadata = new GenerateMetadata();
                        if (flag)
                        {
                            name = metadata.GetAssemblyName(SrcTlbPath, PhysicalPath + @"bin\");
                        }
                        else
                        {
                            name = metadata.GenerateSigned(SrcTlbPath, PhysicalPath + @"bin\", false, out Error);
                        }
                        if (!string.IsNullOrEmpty(name))
                        {
                            try
                            {
                                TypeName = this.GetTypeNameFromProgId(PhysicalPath + @"bin\" + name + ".dll", ProgId);
                            }
                            catch (DirectoryNotFoundException)
                            {
                                if (!flag)
                                {
                                    throw;
                                }
                            }
                            catch (FileNotFoundException)
                            {
                                if (!flag)
                                {
                                    throw;
                                }
                            }
                        }
                    }
                    if ((!string.IsNullOrEmpty(ProgId) && !string.IsNullOrEmpty(name)) && !string.IsNullOrEmpty(TypeName))
                    {
                        ServerWebConfig config       = new ServerWebConfig();
                        DiscoFile       file         = new DiscoFile();
                        string          assemblyFile = PhysicalPath + @"bin\" + name + ".dll";
                        if (flag)
                        {
                            config.DeleteElement(PhysicalPath + "Web.Config", name, TypeName, ProgId, "SingleCall", assemblyFile);
                            file.DeleteElement(PhysicalPath + "Default.disco", ProgId + ".soap?WSDL");
                        }
                        else
                        {
                            config.AddGacElement(PhysicalPath + "Web.Config", name, TypeName, ProgId, "SingleCall", assemblyFile);
                            file.AddElement(PhysicalPath + "Default.disco", ProgId + ".soap?WSDL");
                        }
                    }
                    if (!string.IsNullOrEmpty(name))
                    {
                        string fileName = PhysicalPath + @"bin\" + name + ".dll";
                        strAssemblyName = new AssemblyManager().GetFullName(fileName);
                    }
                }
            }
            catch (Exception exception)
            {
                if ((exception is NullReferenceException) || (exception is SEHException))
                {
                    throw;
                }
                Error = exception.ToString();
                ComSoapPublishError.Report(Error);
                if ((typeof(ServicedComponentException) == exception.GetType()) || (typeof(RegistrationException) == exception.GetType()))
                {
                    throw;
                }
            }
        }
 public void CreateVirtualRoot(string Operation, string FullUrl, out string BaseUrl, out string VirtualRoot, out string PhysicalPath, out string Error)
 {
     BaseUrl      = "";
     VirtualRoot  = "";
     PhysicalPath = "";
     Error        = "";
     if (FullUrl.Length > 0)
     {
         try
         {
             new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
             ParseUrl(FullUrl, out BaseUrl, out VirtualRoot);
             if (VirtualRoot.Length > 0)
             {
                 string rootWeb   = "IIS://localhost/W3SVC/1/ROOT";
                 bool   createDir = true;
                 if ((Operation.ToLower(CultureInfo.InvariantCulture) == "delete") || (Operation.ToLower(CultureInfo.InvariantCulture) == "addcomponent"))
                 {
                     createDir = false;
                 }
                 string binDirectory = "";
                 this.GetVRootPhysicalPath(VirtualRoot, out PhysicalPath, out binDirectory, createDir);
                 if (PhysicalPath.Length <= 0)
                 {
                     Error = Resource.FormatString("Soap_VRootDirectoryCreationFailed");
                 }
                 else if (createDir)
                 {
                     ServerWebConfig config = new ServerWebConfig();
                     string          error  = "";
                     config.Create(PhysicalPath, "Web", out error);
                     new DiscoFile().Create(PhysicalPath, "Default.disco");
                     new HomePage().Create(PhysicalPath, VirtualRoot, "Default.aspx", "Default.disco");
                     string str4 = "";
                     try
                     {
                         new IISVirtualRoot().Create(rootWeb, PhysicalPath, VirtualRoot, out str4);
                     }
                     catch (Exception exception)
                     {
                         if ((exception is NullReferenceException) || (exception is SEHException))
                         {
                             throw;
                         }
                         if (str4.Length <= 0)
                         {
                             string str5 = Resource.FormatString("Soap_VRootCreationFailed");
                             str4 = string.Format(CultureInfo.CurrentCulture, str5 + " " + VirtualRoot + " " + exception.ToString(), new object[0]);
                         }
                     }
                     if (str4.Length > 0)
                     {
                         Error = str4;
                     }
                 }
             }
         }
         catch (Exception exception2)
         {
             if ((exception2 is NullReferenceException) || (exception2 is SEHException))
             {
                 throw;
             }
             Error = exception2.ToString();
             ComSoapPublishError.Report(Error);
         }
     }
 }