public object CreateFromAssembly(string AssemblyName, string TypeName, string Mode)
        {
            object obj3;

            try
            {
                Assembly assembly;
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
                if (AssemblyName.StartsWith("System.EnterpriseServices", StringComparison.Ordinal))
                {
                    return(null);
                }
                string path = Publish.GetClientPhysicalPath(false) + TypeName + ".config";
                if (File.Exists(path))
                {
                    lock (_htTypes)
                    {
                        if (!_htTypes.ContainsKey(path))
                        {
                            RemotingConfiguration.Configure(path, false);
                            _htTypes.Add(path, path);
                        }
                        goto Label_0092;
                    }
                }
                throw new COMException(Resource.FormatString("Err_ClassNotReg"), -2147221164);
Label_0092:
                assembly = Assembly.Load(AssemblyName);
                if (null == assembly)
                {
                    throw new COMException(Resource.FormatString("Err_ClassNotReg"), -2147221164);
                }
                object obj2 = assembly.CreateInstance(TypeName);
                if (obj2 == null)
                {
                    throw new COMException(Resource.FormatString("Err_ClassNotReg"), -2147221164);
                }
                obj3 = obj2;
            }
            catch (Exception exception)
            {
                if ((exception is NullReferenceException) || (exception is SEHException))
                {
                    throw;
                }
                ComSoapPublishError.Report(exception.ToString());
                throw;
            }
            return(obj3);
        }
예제 #2
0
 /// <include file='doc\factory.uex' path='docs/doc[@for="ClrObjectFactory.CreateFromAssembly"]/*' />
 public object CreateFromAssembly(string AssemblyName, string TypeName, string Mode)
 {
     try
     {
         SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
         sp.Demand();
         // check to ensure this call is not being used to activate private classes in our assembly
         if (AssemblyName.StartsWith("System.EnterpriseServices"))
         {
             return(null);
         }
         string PhysicalPath = Publish.GetClientPhysicalPath(false);
         string cfgName      = PhysicalPath + TypeName + ".config";
         // we only remote activate if there is a configuration file in this case
         {
             if (File.Exists(cfgName))
             {
                 lock (_htTypes)
                     if (!_htTypes.ContainsKey(cfgName))
                     {
                         RemotingConfiguration.Configure(cfgName);
                         _htTypes.Add(cfgName, cfgName);
                     }
             }
             else //COM+ 26264 - no configuration file is an error condition
             {
                 throw new COMException(Resource.FormatString("Err_ClassNotReg"), Util.REGDB_E_CLASSNOTREG);
             }
         }
         Assembly objAssem = Assembly.LoadWithPartialName(AssemblyName);
         if (null == objAssem)
         {
             throw new COMException(Resource.FormatString("Err_ClassNotReg"), Util.REGDB_E_CLASSNOTREG);
         }
         Object o = objAssem.CreateInstance(TypeName);
         if (null == o)
         {
             throw new COMException(Resource.FormatString("Err_ClassNotReg"), Util.REGDB_E_CLASSNOTREG);
         }
         return(o);
     }
     catch (Exception e)
     {
         ComSoapPublishError.Report(e.ToString());
         throw;
     }
 }
        public object CreateFromWsdl(string WsdlUrl, string Mode)
        {
            object obj3;

            try
            {
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
                string clientPhysicalPath = Publish.GetClientPhysicalPath(true);
                string typeName           = "";
                string str3 = this.Url2File(WsdlUrl);
                if ((str3.Length + clientPhysicalPath.Length) > 250)
                {
                    str3 = str3.Remove(0, (str3.Length + clientPhysicalPath.Length) - 250);
                }
                string fileName = str3 + ".dll";
                if (!File.Exists(clientPhysicalPath + fileName))
                {
                    new GenAssemblyFromWsdl().Run(WsdlUrl, fileName, clientPhysicalPath);
                }
                Assembly assembly = Assembly.LoadFrom(clientPhysicalPath + fileName);
                Type[]   types    = assembly.GetTypes();
                for (long i = 0L; i < types.GetLength(0); i += 1L)
                {
                    if (types[(int)((IntPtr)i)].IsClass)
                    {
                        typeName = types[(int)((IntPtr)i)].ToString();
                    }
                }
                obj3 = assembly.CreateInstance(typeName);
            }
            catch (Exception exception)
            {
                if ((exception is NullReferenceException) || (exception is SEHException))
                {
                    throw;
                }
                ComSoapPublishError.Report(exception.ToString());
                throw;
            }
            return(obj3);
        }
예제 #4
0
 /// <include file='doc\factory.uex' path='docs/doc[@for="ClrObjectFactory.CreateFromWsdl"]/*' />
 public object CreateFromWsdl(string WsdlUrl, string Mode)
 {
     try
     {
         SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
         sp.Demand();
         string PhysicalPath = Publish.GetClientPhysicalPath(true);
         string TypeName     = "";
         string EscUrl       = Url2File(WsdlUrl);
         if ((EscUrl.Length + PhysicalPath.Length) > 250)
         {
             EscUrl = EscUrl.Remove(0, (EscUrl.Length + PhysicalPath.Length) - 250);
         }
         string dllName = EscUrl + ".dll";
         if (!File.Exists(PhysicalPath + dllName))
         {
             GenAssemblyFromWsdl gen = new GenAssemblyFromWsdl();
             gen.Run(WsdlUrl, dllName, PhysicalPath);
         }
         Assembly objAssem   = Assembly.LoadFrom(PhysicalPath + dllName);
         Type[]   AssemTypes = objAssem.GetTypes();
         for (long i = 0; i < AssemTypes.GetLength(0); i++)
         {
             if (AssemTypes[i].IsClass)
             {
                 TypeName = AssemTypes[i].ToString();
             }
         }
         Object o = objAssem.CreateInstance(TypeName);
         return(o);
     }
     catch (Exception e)
     {
         ComSoapPublishError.Report(e.ToString());
         throw;
     }
 }