AppDomain.CreateInstanceFromAndUnwrap 方法

定义

创建在指定程序集文件中定义的指定类型的新实例。

重载

CreateInstanceFromAndUnwrap(String, String)

创建在指定程序集文件中定义的指定类型的新实例。

CreateInstanceFromAndUnwrap(String, String, Object[])

创建在指定程序集文件中定义的指定类型的新实例。

CreateInstanceFromAndUnwrap(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])

创建在指定的程序集文件中定义的指定类型的新实例,指定是否忽略类型名称的大小写,并指定绑定特性和用于选择要创建的类型的联编程序、构造函数的自变量、区域性以及激活特性。

CreateInstanceFromAndUnwrap(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[], Evidence)
已过时.

创建在指定程序集文件中定义的指定类型的新实例。

CreateInstanceFromAndUnwrap(String, String)

Source:
AppDomain.cs
Source:
AppDomain.cs
Source:
AppDomain.cs

创建在指定程序集文件中定义的指定类型的新实例。

public:
 System::Object ^ CreateInstanceFromAndUnwrap(System::String ^ assemblyFile, System::String ^ typeName);
public:
 System::Object ^ CreateInstanceFromAndUnwrap(System::String ^ assemblyName, System::String ^ typeName);
public object? CreateInstanceFromAndUnwrap (string assemblyFile, string typeName);
public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName);
member this.CreateInstanceFromAndUnwrap : string * string -> obj
member this.CreateInstanceFromAndUnwrap : string * string -> obj
Public Function CreateInstanceFromAndUnwrap (assemblyFile As String, typeName As String) As Object
Public Function CreateInstanceFromAndUnwrap (assemblyName As String, typeName As String) As Object

参数

assemblyFileassemblyName
String
typeName
String

FullName 属性返回的所请求类型的完全限定名称,包含命名空间而不是程序集。

返回

请求的对象,或者如果找不到 typeName 则返回 null

例外

assemblyNamenull

typeNamenull

在卸载的应用程序域上尝试该操作。

未找到 assemblyName

assemblyName 中未找到 typeName

未找到无形参的公共构造函数。

调用方没有足够的权限调用此构造函数。

assemblyName 对于当前加载的运行时,不是有效的程序集。

一个程序集或模块用两个不同的证据加载了两次。

注解

这是一种将 和 ObjectHandle.Unwrap组合在一起的CreateInstanceFrom便捷方法。 此方法调用 的 typeName无参数构造函数。

有关更多信息,请参见 Activator.CreateInstanceFrom 方法。

另请参阅

适用于

CreateInstanceFromAndUnwrap(String, String, Object[])

Source:
AppDomain.cs
Source:
AppDomain.cs
Source:
AppDomain.cs

创建在指定程序集文件中定义的指定类型的新实例。

public:
 System::Object ^ CreateInstanceFromAndUnwrap(System::String ^ assemblyFile, System::String ^ typeName, cli::array <System::Object ^> ^ activationAttributes);
public:
 System::Object ^ CreateInstanceFromAndUnwrap(System::String ^ assemblyName, System::String ^ typeName, cli::array <System::Object ^> ^ activationAttributes);
public object? CreateInstanceFromAndUnwrap (string assemblyFile, string typeName, object?[]? activationAttributes);
public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, object[] activationAttributes);
member this.CreateInstanceFromAndUnwrap : string * string * obj[] -> obj
member this.CreateInstanceFromAndUnwrap : string * string * obj[] -> obj
Public Function CreateInstanceFromAndUnwrap (assemblyFile As String, typeName As String, activationAttributes As Object()) As Object
Public Function CreateInstanceFromAndUnwrap (assemblyName As String, typeName As String, activationAttributes As Object()) As Object

参数

assemblyFileassemblyName
String
typeName
String

所请求类型的完全限定名,包括命名空间而不是程序集(请参见 FullName 属性)。

activationAttributes
Object[]

包含一个或多个可以参与激活的特性的数组。 通常,为包含单个 UrlAttribute 对象的数组,该对象指定激活远程对象所需的 URL。

此参数与客户端激活的对象相关。客户端激活是一项传统技术,保留用于向后兼容,但不建议用于新的开发。 应改用 Windows Communication Foundation 来开发分布式应用程序。

返回

请求的对象,或者如果找不到 typeName 则返回 null

例外

assemblyNamenull

typeNamenull

调用方不能为非继承自 MarshalByRefObject 的对象提供激活属性。

在卸载的应用程序域上尝试该操作。

未找到 assemblyName

assemblyName 中未找到 typeName

未找到无形参的公共构造函数。

调用方没有足够的权限调用此构造函数。

assemblyName 对于当前加载的运行时,不是有效的程序集。

一个程序集或模块用两个不同的证据加载了两次。

注解

这是一种将 和 ObjectHandle.Unwrap组合在一起的CreateInstanceFrom便捷方法。 此方法调用 的 typeName无参数构造函数。

有关此方法的详细信息,请参阅 Activator.CreateInstanceFrom 方法。

另请参阅

适用于

CreateInstanceFromAndUnwrap(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])

Source:
AppDomain.cs
Source:
AppDomain.cs
Source:
AppDomain.cs

创建在指定的程序集文件中定义的指定类型的新实例,指定是否忽略类型名称的大小写,并指定绑定特性和用于选择要创建的类型的联编程序、构造函数的自变量、区域性以及激活特性。

public:
 System::Object ^ CreateInstanceFromAndUnwrap(System::String ^ assemblyFile, System::String ^ typeName, bool ignoreCase, System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, cli::array <System::Object ^> ^ args, System::Globalization::CultureInfo ^ culture, cli::array <System::Object ^> ^ activationAttributes);
public object? CreateInstanceFromAndUnwrap (string assemblyFile, string typeName, bool ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, object?[]? args, System.Globalization.CultureInfo? culture, object?[]? activationAttributes);
public object CreateInstanceFromAndUnwrap (string assemblyFile, string typeName, bool ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture, object[] activationAttributes);
member this.CreateInstanceFromAndUnwrap : string * string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo * obj[] -> obj
Public Function CreateInstanceFromAndUnwrap (assemblyFile As String, typeName As String, ignoreCase As Boolean, bindingAttr As BindingFlags, binder As Binder, args As Object(), culture As CultureInfo, activationAttributes As Object()) As Object

参数

assemblyFile
String

定义所请求类型的程序集的文件名和路径。

typeName
String

FullName 属性返回的所请求类型的完全限定名称,包含命名空间而不是程序集。

ignoreCase
Boolean

一个布尔值,指示是否执行区分大小写的搜索。

bindingAttr
BindingFlags

影响 typeName 构造函数搜索的零个或多个位标志的组合。 如果 bindingAttr 为零,则对公共构造函数进行区分大小写的搜索。

binder
Binder

一个对象,它启用绑定、对参数类型的强制、对成员的调用,以及通过反射对 MemberInfo 对象的检索。 如果 binder 为 null,则使用默认联编程序。

args
Object[]

要传递给构造函数的实参。 此实参数组必须在数量、顺序和类型方面与要调用的构造函数的形参匹配。 如果无参数构造函数是首选,则 args 必须为空数组或 NULL。

culture
CultureInfo

区域性特定的信息,这些信息控制将 args 强制转换为 typeName 构造函数所声明的正式类型。 如果 culturenull,则使用当前线程的 CultureInfo

activationAttributes
Object[]

包含一个或多个可以参与激活的特性的数组。 通常,为包含单个 UrlAttribute 对象的数组,该对象指定激活远程对象所需的 URL。

此参数与客户端激活的对象相关。 客户端激活是一项传统技术,保留用于向后兼容,但不建议用于新的开发。 应改用 Windows Communication Foundation 来开发分布式应用程序。

返回

请求的对象,或者如果找不到 typeName 则返回 null

例外

assemblyNamenull

typeNamenull

调用方不能为非继承自 MarshalByRefObject 的对象提供激活属性。

在卸载的应用程序域上尝试该操作。

未找到 assemblyName

assemblyName 中未找到 typeName

未找到匹配的公共构造函数。

调用方没有足够的权限调用此构造函数。

assemblyName 不是有效的程序集。

- 或 -

assemblyName 使用高于当前所加载版本的公共语言运行时版本编译而成。

一个程序集或模块用两个不同的证据加载了两次。

注解

这是一种将 和 ObjectHandle.Unwrap组合在一起的CreateInstanceFrom便捷方法。

有关此方法的详细信息,请参阅 Activator.CreateInstanceFrom 方法。

另请参阅

适用于

CreateInstanceFromAndUnwrap(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[], Evidence)

注意

Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstanceFromAndUnwrap which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

创建在指定程序集文件中定义的指定类型的新实例。

public:
 System::Object ^ CreateInstanceFromAndUnwrap(System::String ^ assemblyName, System::String ^ typeName, bool ignoreCase, System::Reflection::BindingFlags bindingAttr, System::Reflection::Binder ^ binder, cli::array <System::Object ^> ^ args, System::Globalization::CultureInfo ^ culture, cli::array <System::Object ^> ^ activationAttributes, System::Security::Policy::Evidence ^ securityAttributes);
public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, bool ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture, object[] activationAttributes, System.Security.Policy.Evidence securityAttributes);
[System.Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstanceFromAndUnwrap which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, bool ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture, object[] activationAttributes, System.Security.Policy.Evidence securityAttributes);
member this.CreateInstanceFromAndUnwrap : string * string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo * obj[] * System.Security.Policy.Evidence -> obj
[<System.Obsolete("Methods which use evidence to sandbox are obsolete and will be removed in a future release of the .NET Framework. Please use an overload of CreateInstanceFromAndUnwrap which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
member this.CreateInstanceFromAndUnwrap : string * string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo * obj[] * System.Security.Policy.Evidence -> obj
Public Function CreateInstanceFromAndUnwrap (assemblyName As String, typeName As String, ignoreCase As Boolean, bindingAttr As BindingFlags, binder As Binder, args As Object(), culture As CultureInfo, activationAttributes As Object(), securityAttributes As Evidence) As Object

参数

assemblyName
String

定义所请求类型的程序集的文件名和路径。

typeName
String

FullName 属性返回的所请求类型的完全限定名称,包含命名空间而不是程序集。

ignoreCase
Boolean

一个布尔值,指示是否执行区分大小写的搜索。

bindingAttr
BindingFlags

影响 typeName 构造函数搜索的零个或多个位标志的组合。 如果 bindingAttr 为零,则对公共构造函数进行区分大小写的搜索。

binder
Binder

一个对象,它启用绑定、对参数类型的强制、对成员的调用,以及通过反射对 MemberInfo 对象的检索。 如果 binder 为 null,则使用默认联编程序。

args
Object[]

要传递给构造函数的实参。 此实参数组必须在数量、顺序和类型方面与要调用的构造函数的形参匹配。 如果无参数构造函数是首选,则 args 必须为空数组或 NULL。

culture
CultureInfo

区域性特定的信息,这些信息控制将 args 强制转换为 typeName 构造函数所声明的正式类型。 如果 culturenull,则使用当前线程的 CultureInfo

activationAttributes
Object[]

包含一个或多个可以参与激活的特性的数组。 通常,为包含单个 UrlAttribute 对象的数组,该对象指定激活远程对象所需的 URL。

此参数与客户端激活的对象相关。 客户端激活是一项传统技术,保留用于向后兼容,但不建议用于新的开发。 应改用 Windows Communication Foundation 来开发分布式应用程序。

securityAttributes
Evidence

用于授权创建 typeName 的信息。

返回

请求的对象,或者如果找不到 typeName 则返回 null

属性

例外

assemblyNamenull

typeNamenull

调用方不能为非继承自 MarshalByRefObject 的对象提供激活属性。

在卸载的应用程序域上尝试该操作。

未找到 assemblyName

assemblyName 中未找到 typeName

未找到匹配的公共构造函数。

调用方没有足够的权限调用此构造函数。

assemblyName 对于当前加载的运行时,不是有效的程序集。

一个程序集或模块用两个不同的证据加载了两次。

注解

这是一种将 和 ObjectHandle.Unwrap组合在一起的CreateInstanceFrom便捷方法。

有关此方法的详细信息,请参阅 Activator.CreateInstanceFrom 方法。

另请参阅

适用于