AppDomain.CreateInstanceFrom 메서드

정의

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

오버로드

CreateInstanceFrom(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[], Evidence)
사용되지 않음.

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

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

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

CreateInstanceFrom(String, String, Object[])

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

CreateInstanceFrom(String, String)

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

CreateInstanceFrom(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 CreateInstanceFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

public:
 virtual System::Runtime::Remoting::ObjectHandle ^ CreateInstanceFrom(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, System::Security::Policy::Evidence ^ securityAttributes);
public System.Runtime.Remoting.ObjectHandle CreateInstanceFrom (string assemblyFile, 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 CreateInstanceFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public System.Runtime.Remoting.ObjectHandle CreateInstanceFrom (string assemblyFile, 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);
abstract member CreateInstanceFrom : string * string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo * obj[] * System.Security.Policy.Evidence -> System.Runtime.Remoting.ObjectHandle
override this.CreateInstanceFrom : string * string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo * obj[] * System.Security.Policy.Evidence -> System.Runtime.Remoting.ObjectHandle
[<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 CreateInstanceFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
abstract member CreateInstanceFrom : string * string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo * obj[] * System.Security.Policy.Evidence -> System.Runtime.Remoting.ObjectHandle
override this.CreateInstanceFrom : string * string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo * obj[] * System.Security.Policy.Evidence -> System.Runtime.Remoting.ObjectHandle
Public Function CreateInstanceFrom (assemblyFile 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 ObjectHandle

매개 변수

assemblyFile
String

경로를 포함하여 요청된 형식을 정의하는 어셈블리가 포함된 파일 이름입니다. 어셈블리는 LoadFrom(String) 메서드를 사용하여 로드됩니다.

typeName
String

네임스페이스만 포함하고 어셈블리는 포함하지 않는 요청된 형식의 정규화된 이름으로, FullName 속성에 의해 반환됩니다.

ignoreCase
Boolean

검색할 때 대/소문자를 구분할지를 지정하는 부울 값입니다.

bindingAttr
BindingFlags

typeName 생성자 검색에 영향을 미치는 0 또는 그 이상의 비트 플래그 조합입니다. bindingAttr가 0이면 대/소문자를 구분한 public 생성자 검색이 수행됩니다.

binder
Binder

리플렉션을 통해 바인딩, 인수 형식의 강제 변환, 멤버 호출 및 MemberInfo 개체 검색을 사용할 수 있도록 하는 개체입니다. binder가 null이면 기본 바인더가 사용됩니다.

args
Object[]

생성자에 전달할 인수입니다. 이 인수 배열은 호출할 생성자의 매개 변수와 개수, 순서 및 형식이 일치해야 합니다. 매개 변수가 없는 생성자를 사용하려면 args가 빈 배열이거나 null이어야 합니다.

culture
CultureInfo

typeName 생성자에 대해 선언된 공식적인 형식에 args를 강제로 적용하는 것을 제어하는 문화권별 정보입니다. culturenull이면 현재 스레드의 CultureInfo가 사용됩니다.

activationAttributes
Object[]

활성화할 수 있는 하나 이상의 특성으로 이루어진 배열입니다. 일반적으로, 원격 개체를 활성화하는 데 필요한 URL을 지정하는 단일 UrlAttribute 개체가 포함된 배열입니다.

이 매개 변수는 클라이언트 활성 개체와 관련되어 있습니다. 클라이언트 활성화는 이전 버전과의 호환성을 위해 유지되지만 새로운 개발에는 권장되지 않는 레거시 기술입니다. 분산된 애플리케이션은 Windows Communication Foundation을 사용해야 합니다.

securityAttributes
Evidence

typeName의 생성을 인증하는 데 사용하는 정보입니다.

반환

새 인스턴스에 대한 래퍼인 개체이거나, typeName이 없는 경우 null입니다. 실제 개체에 액세스하려면 반환 값은 래핑되지 않아야 합니다.

구현

특성

예외

assemblyFile이(가) null인 경우

또는

typeName이(가) null인 경우

호출자가 MarshalByRefObject에서 상속되지 않는 개체에 대한 활성화 특성을 제공할 수 없습니다.

또는

securityAttributesnull가 아닙니다. 레거시 CAS 정책을 사용하지 않을 때는 securityAttributesnull이 되어야 합니다.

언로드된 애플리케이션 도메인에서 작업이 시도됩니다.

assemblyFile을 찾을 수 없습니다.

assemblyFile에서 typeName을 찾을 수 없습니다.

일치하는 public 생성자를 찾을 수 없습니다.

호출자에게 이 생성자를 호출할 수 있는 충분한 권한이 없습니다.

assemblyFile 는 현재 로드된 런타임에 유효한 어셈블리가 아닙니다.

어셈블리 또는 모듈이 서로 다른 두 증명 정보로 두 번 로드되었습니다.

이 인스턴스가 null인 경우

설명

이 메서드에 대한 자세한 내용은 메서드를 참조하세요 Activator.CreateInstanceFrom .

경우는 CreateInstanceFrom 메서드는 호출 되는 애플리케이션 도메인 이외의 대상 애플리케이션 도메인에서 인스턴스를 만드는 데, 어셈블리는 대상 애플리케이션 도메인에 로드 됩니다. 그러나 인스턴스 호출 애플리케이션 도메인에서 래핑 해제 된 경우 특정 방식으로 래핑되지 않은 인스턴스를 사용 하 여 호출 애플리케이션 도메인에 로드 될 어셈블리를 발생할 수 있습니다. 예를 들어 instance 래핑 해제된 후 해당 메서드를 늦게 바인딩된 메서드를 호출하기 위해 해당 형식 정보를 요청할 수 있습니다. 어셈블리 호출 애플리케이션 도메인에 로드 되 면 예외가 발생할 수 있습니다.

  • 동일한 어셈블리의 다른 버전 이전에 호출 애플리케이션 도메인에 로드 하는 경우 또는 호출 애플리케이션 도메인의 로드 경로 같은 대상 애플리케이션 도메인, 예외와 다른 경우 MissingMethodException 발생할 수 있습니다.

  • 호출 애플리케이션 도메인 인스턴스 형식의 초기 바인딩 호출 하는 경우 InvalidCastException 인스턴스 캐스팅 하려고 시도 하는 경우에 throw 될 수 있습니다.

추가 정보

적용 대상

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

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

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

public:
 System::Runtime::Remoting::ObjectHandle ^ CreateInstanceFrom(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 System.Runtime.Remoting.ObjectHandle? CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder? binder, object?[]? args, System.Globalization.CultureInfo? culture, object?[]? activationAttributes);
public System.Runtime.Remoting.ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, bool ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture, object[] activationAttributes);
member this.CreateInstanceFrom : string * string * bool * System.Reflection.BindingFlags * System.Reflection.Binder * obj[] * System.Globalization.CultureInfo * obj[] -> System.Runtime.Remoting.ObjectHandle
Public Function CreateInstanceFrom (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 ObjectHandle

매개 변수

assemblyFile
String

경로를 포함하여 요청된 형식을 정의하는 어셈블리가 포함된 파일 이름입니다. 어셈블리는 LoadFrom(String) 메서드를 사용하여 로드됩니다.

typeName
String

네임스페이스만 포함하고 어셈블리는 포함하지 않는 요청된 형식의 정규화된 이름으로, FullName 속성에 의해 반환됩니다.

ignoreCase
Boolean

검색할 때 대/소문자를 구분할지를 지정하는 부울 값입니다.

bindingAttr
BindingFlags

typeName 생성자 검색에 영향을 미치는 0 또는 그 이상의 비트 플래그 조합입니다. bindingAttr가 0이면 대/소문자를 구분한 public 생성자 검색이 수행됩니다.

binder
Binder

리플렉션을 통해 바인딩, 인수 형식의 강제 변환, 멤버 호출 및 MemberInfo 개체 검색을 사용할 수 있도록 하는 개체입니다. binder가 null이면 기본 바인더가 사용됩니다.

args
Object[]

생성자에 전달할 인수입니다. 이 인수 배열은 호출할 생성자의 매개 변수와 개수, 순서 및 형식이 일치해야 합니다. 매개 변수가 없는 생성자를 사용하려면 args가 빈 배열이거나 null이어야 합니다.

culture
CultureInfo

typeName 생성자에 대해 선언된 공식적인 형식에 args를 강제로 적용하는 것을 제어하는 문화권별 정보입니다. culturenull이면 현재 스레드의 CultureInfo가 사용됩니다.

activationAttributes
Object[]

활성화할 수 있는 하나 이상의 특성으로 이루어진 배열입니다. 일반적으로, 원격 개체를 활성화하는 데 필요한 URL을 지정하는 단일 UrlAttribute 개체가 포함된 배열입니다.

이 매개 변수는 클라이언트 활성 개체와 관련되어 있습니다. 클라이언트 활성화는 이전 버전과의 호환성을 위해 유지되지만 새로운 개발에는 권장되지 않는 레거시 기술입니다. 분산된 애플리케이션은 Windows Communication Foundation을 사용해야 합니다.

반환

새 인스턴스에 대한 래퍼인 개체이거나, typeName이 없는 경우 null입니다. 실제 개체에 액세스하려면 반환 값은 래핑되지 않아야 합니다.

예외

assemblyFilenull입니다.

또는

typeName이(가) null인 경우

호출자가 MarshalByRefObject에서 상속되지 않는 개체에 대한 활성화 특성을 제공할 수 없습니다.

언로드된 애플리케이션 도메인에서 작업이 시도됩니다.

assemblyFile을 찾을 수 없습니다.

assemblyFile에서 typeName을 찾을 수 없습니다.

일치하는 public 생성자를 찾을 수 없습니다.

호출자에게 이 생성자를 호출할 수 있는 충분한 권한이 없습니다.

assemblyFile 는 현재 로드된 런타임에 유효한 어셈블리가 아닙니다.

어셈블리 또는 모듈이 서로 다른 두 증명 정보로 두 번 로드되었습니다.

이 인스턴스가 null인 경우

설명

자세한 내용은 Activator.CreateInstanceFrom 메서드를 참조하세요.

경우는 CreateInstanceFrom 메서드는 호출 되는 애플리케이션 도메인 이외의 대상 애플리케이션 도메인에서 인스턴스를 만드는 데, 어셈블리는 대상 애플리케이션 도메인에 로드 됩니다. 그러나 인스턴스 호출 애플리케이션 도메인에서 래핑 해제 된 경우 특정 방식으로 래핑되지 않은 인스턴스를 사용 하 여 호출 애플리케이션 도메인에 로드 될 어셈블리를 발생할 수 있습니다. 예를 들어 instance 래핑 해제된 후 해당 메서드를 늦게 바인딩된 메서드를 호출하기 위해 해당 형식 정보를 요청할 수 있습니다. 어셈블리 호출 애플리케이션 도메인에 로드 되 면 예외가 발생할 수 있습니다.

  • 동일한 어셈블리의 다른 버전 이전에 호출 애플리케이션 도메인에 로드 하는 경우 또는 호출 애플리케이션 도메인의 로드 경로 같은 대상 애플리케이션 도메인, 예외와 다른 경우 MissingMethodException 발생할 수 있습니다.

  • 호출 애플리케이션 도메인 인스턴스 형식의 초기 바인딩 호출 하는 경우 InvalidCastException 인스턴스 캐스팅 하려고 시도 하는 경우에 throw 될 수 있습니다.

추가 정보

적용 대상

CreateInstanceFrom(String, String, Object[])

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

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

public:
 System::Runtime::Remoting::ObjectHandle ^ CreateInstanceFrom(System::String ^ assemblyFile, System::String ^ typeName, cli::array <System::Object ^> ^ activationAttributes);
public:
 virtual System::Runtime::Remoting::ObjectHandle ^ CreateInstanceFrom(System::String ^ assemblyFile, System::String ^ typeName, cli::array <System::Object ^> ^ activationAttributes);
public System.Runtime.Remoting.ObjectHandle? CreateInstanceFrom (string assemblyFile, string typeName, object?[]? activationAttributes);
public System.Runtime.Remoting.ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName, object[] activationAttributes);
member this.CreateInstanceFrom : string * string * obj[] -> System.Runtime.Remoting.ObjectHandle
abstract member CreateInstanceFrom : string * string * obj[] -> System.Runtime.Remoting.ObjectHandle
override this.CreateInstanceFrom : string * string * obj[] -> System.Runtime.Remoting.ObjectHandle
Public Function CreateInstanceFrom (assemblyFile As String, typeName As String, activationAttributes As Object()) As ObjectHandle

매개 변수

assemblyFile
String

경로를 포함하여 요청된 형식을 정의하는 어셈블리가 포함된 파일 이름입니다. 어셈블리는 LoadFrom(String) 메서드를 사용하여 로드됩니다.

typeName
String

네임스페이스만 포함하고 어셈블리는 포함하지 않는 요청된 형식의 정규화된 이름으로, FullName 속성에 의해 반환됩니다.

activationAttributes
Object[]

활성화할 수 있는 하나 이상의 특성으로 이루어진 배열입니다. 일반적으로, 원격 개체를 활성화하는 데 필요한 URL을 지정하는 단일 UrlAttribute 개체가 포함된 배열입니다.

이 매개 변수는 클라이언트 활성 개체와 관련이 있습니다. 클라이언트 활성화는 이전 버전과의 호환성을 위해 유지되지만 새로운 개발에는 권장되지 않는 레거시 기술입니다. 분산된 애플리케이션은 Windows Communication Foundation을 사용해야 합니다.

반환

새 인스턴스에 대한 래퍼인 개체이거나, typeName이 없는 경우 null입니다. 실제 개체에 액세스하려면 반환 값은 래핑되지 않아야 합니다.

구현

예외

assemblyFile이(가) null인 경우

assemblyFile을 찾을 수 없습니다.

assemblyFile에서 typeName을 찾을 수 없습니다.

호출자에게 이 생성자를 호출할 수 있는 충분한 권한이 없습니다.

일치하는 public 생성자를 찾을 수 없습니다.

호출자가 MarshalByRefObject에서 상속되지 않는 개체에 대한 활성화 특성을 제공할 수 없습니다.

언로드된 애플리케이션 도메인에서 작업이 시도됩니다.

assemblyFile 는 현재 로드된 런타임에 유효한 어셈블리가 아닙니다.

어셈블리 또는 모듈이 서로 다른 두 증명 정보로 두 번 로드되었습니다.

이 인스턴스가 null인 경우

설명

에 대한 typeName 매개 변수가 없는 생성자가 호출됩니다.

이 메서드에 대한 자세한 내용은 메서드를 참조하세요 Activator.CreateInstanceFrom .

경우는 CreateInstanceFrom 메서드는 호출 되는 애플리케이션 도메인 이외의 대상 애플리케이션 도메인에서 인스턴스를 만드는 데, 어셈블리는 대상 애플리케이션 도메인에 로드 됩니다. 그러나 인스턴스 호출 애플리케이션 도메인에서 래핑 해제 된 경우 특정 방식으로 래핑되지 않은 인스턴스를 사용 하 여 호출 애플리케이션 도메인에 로드 될 어셈블리를 발생할 수 있습니다. 예를 들어 instance 래핑 해제된 후 해당 메서드를 늦게 바인딩된 메서드를 호출하기 위해 해당 형식 정보를 요청할 수 있습니다. 어셈블리 호출 애플리케이션 도메인에 로드 되 면 예외가 발생할 수 있습니다.

  • 동일한 어셈블리의 다른 버전 이전에 호출 애플리케이션 도메인에 로드 하는 경우 또는 호출 애플리케이션 도메인의 로드 경로 같은 대상 애플리케이션 도메인, 예외와 다른 경우 MissingMethodException 발생할 수 있습니다.

  • 호출 애플리케이션 도메인 인스턴스 형식의 초기 바인딩 호출 하는 경우 InvalidCastException 인스턴스 캐스팅 하려고 시도 하는 경우에 throw 될 수 있습니다.

추가 정보

적용 대상

CreateInstanceFrom(String, String)

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

지정한 어셈블리 파일에 정의된 지정한 형식의 새 인스턴스를 만듭니다.

public:
 System::Runtime::Remoting::ObjectHandle ^ CreateInstanceFrom(System::String ^ assemblyFile, System::String ^ typeName);
public:
 virtual System::Runtime::Remoting::ObjectHandle ^ CreateInstanceFrom(System::String ^ assemblyFile, System::String ^ typeName);
public System.Runtime.Remoting.ObjectHandle? CreateInstanceFrom (string assemblyFile, string typeName);
public System.Runtime.Remoting.ObjectHandle CreateInstanceFrom (string assemblyFile, string typeName);
member this.CreateInstanceFrom : string * string -> System.Runtime.Remoting.ObjectHandle
abstract member CreateInstanceFrom : string * string -> System.Runtime.Remoting.ObjectHandle
override this.CreateInstanceFrom : string * string -> System.Runtime.Remoting.ObjectHandle
Public Function CreateInstanceFrom (assemblyFile As String, typeName As String) As ObjectHandle

매개 변수

assemblyFile
String

경로를 포함하여 요청된 형식을 정의하는 어셈블리가 포함된 파일 이름입니다. 어셈블리는 LoadFrom(String) 메서드를 사용하여 로드됩니다.

typeName
String

네임스페이스만 포함하고 어셈블리는 포함하지 않는 요청된 형식의 정규화된 이름으로, FullName 속성에 의해 반환됩니다.

반환

새 인스턴스에 대한 래퍼인 개체이거나, typeName이 없는 경우 null입니다. 실제 개체에 액세스하려면 반환 값은 래핑되지 않아야 합니다.

구현

예외

assemblyFile이(가) null인 경우

또는

typeName이(가) null인 경우

assemblyFile을 찾을 수 없습니다.

assemblyFile에서 typeName을 찾을 수 없습니다.

언로드된 애플리케이션 도메인에서 작업이 시도됩니다.

매개 변수가 없는 public 생성자를 찾지 못한 경우

호출자에게 이 생성자를 호출할 수 있는 충분한 권한이 없습니다.

assemblyFile 는 현재 로드된 런타임에 유효한 어셈블리가 아닙니다.

어셈블리 또는 모듈이 서로 다른 두 증명 정보로 두 번 로드되었습니다.

이 인스턴스가 null인 경우

예제

다음 예제에서는 사용 하는 방법의 CreateInstanceFrom(String, String) 메서드 오버 로드를 대상 애플리케이션 도메인에서 개체의 인스턴스를 만들고 해당 메서드를 호출 합니다.

이 예제에서는 정의 MarshalableExample 클래스를 애플리케이션 도메인 경계를 넘어 마샬링될 수 있습니다. 이 예제에서는 현재 실행 중인 어셈블리에 대 한 경로 빌드, 대상 애플리케이션 도메인을 만들고 사용 하는 CreateInstanceFrom(String, String) 메서드 오버 로드의 인스턴스를 만들고 예제 어셈블리의 대상 애플리케이션 도메인에 로드 MarshalableExample합니다.

참고

이 예제에서는 경로가 절대이지만 메서드가 어셈블리를 로드하는 데 사용되므로 상대 경로도 작동 Assembly.LoadFrom 합니다.

개체 핸들에 대 한 래핑 해제 한 후 예제에 개체를 사용 하는 대상 애플리케이션 도메인에서 세 가지 방법을 보여 줍니다.

  • 리플렉션을 사용하여 늦은 바인딩을 사용하여 메서드를 호출합니다. 이 호출자의 애플리케이션 도메인에 로드 될 어셈블리를 사용 하면 형식 정보가 필요 합니다. (이 예제에서는 이미 로드되어 있습니다.)

  • 호출자와 호출 수신자 모두에게 알려진 인터페이스로 개체를 캐스팅합니다. 인터페이스를 호출 하는 어셈블리 또는 호출자와 호출 수신자에서 참조 하는 세 번째 어셈블리에 정의 된 경우 호출된 된 어셈블리는 호출자의 애플리케이션 도메인에 로드 아닙니다.

  • 호출자에게 형식을 알 수 있는 경우 개체를 직접 사용합니다. 어셈블리는 호출자의 애플리케이션 도메인에 로드 되어야 합니다.

파생 호출자가 호출자의 애플리케이션 도메인에서 호출된 되는 어셈블리 로드 방지 하는 또 다른 방법은 것을 MarshalByRefObject 클래스 및 대상 애플리케이션 도메인에서 실행할 수 있는 메서드를 정의 합니다. 해당 메서드 수 리플렉션을 사용 하 여 대상 어셈블리를 검사할 대상 어셈블리가 이미 대상 애플리케이션 도메인에 로드 하기 때문에 있습니다. 속성에 대한 예제를 DynamicDirectory 참조하세요.

using namespace System;

public interface class ITest
{
    void Test(String^ greeting);
};

public ref class MarshalableExample : MarshalByRefObject, ITest
{
public:
    virtual void Test(String^ greeting)
    {
        Console::WriteLine("{0} from '{1}'!", greeting,
            AppDomain::CurrentDomain->FriendlyName);
    }
};

void main()
{
    // Construct a path to the current assembly.
    String^ assemblyPath = Environment::CurrentDirectory + "\\" +
        MarshalableExample::typeid->Assembly->GetName()->Name + ".exe";

    AppDomain^ ad = AppDomain::CreateDomain("MyDomain");
 
    System::Runtime::Remoting::ObjectHandle^ oh = 
        ad->CreateInstanceFrom(assemblyPath, "MarshalableExample");

    Object^ obj = oh->Unwrap();


    // Three ways to use the newly created object, depending on how
    // much is known about the type: Late bound, early bound through 
    // a mutually known interface, or early binding of a known type.
    //
    obj->GetType()->InvokeMember("Test", 
        System::Reflection::BindingFlags::InvokeMethod, 
        Type::DefaultBinder, obj, gcnew array<Object^> { "Hello" });

    ITest^ it = (ITest^) obj;
    it->Test("Hi");

    MarshalableExample^ ex = (MarshalableExample^) obj;
    ex->Test("Goodbye");
}

/* This example produces the following output:

Hello from 'MyDomain'!
Hi from 'MyDomain'!
Goodbye from 'MyDomain'!
 */
using System;

public interface ITest
{
    void Test(string greeting);
}

public class MarshalableExample : MarshalByRefObject, ITest
{
    static void Main()
    {
        // Construct a path to the current assembly.
        string assemblyPath = Environment.CurrentDirectory + "\\" +
            typeof(MarshalableExample).Assembly.GetName().Name + ".exe";

        AppDomain ad = AppDomain.CreateDomain("MyDomain");

        System.Runtime.Remoting.ObjectHandle oh =
            ad.CreateInstanceFrom(assemblyPath, "MarshalableExample");

        object obj = oh.Unwrap();

        // Three ways to use the newly created object, depending on how
        // much is known about the type: Late bound, early bound through
        // a mutually known interface, or early binding of a known type.
        //
        obj.GetType().InvokeMember("Test",
            System.Reflection.BindingFlags.InvokeMethod,
            Type.DefaultBinder, obj, new object[] { "Hello" });

        ITest it = (ITest) obj;
        it.Test("Hi");

        MarshalableExample ex = (MarshalableExample) obj;
        ex.Test("Goodbye");
    }

    public void Test(string greeting)
    {
        Console.WriteLine("{0} from '{1}'!", greeting,
            AppDomain.CurrentDomain.FriendlyName);
    }
}

/* This example produces the following output:

Hello from 'MyDomain'!
Hi from 'MyDomain'!
Goodbye from 'MyDomain'!
 */
open System

type ITest =
    abstract Test: string -> unit

type MarshalableExample() =
    inherit MarshalByRefObject()
    
    member _.Test greeting =
        printfn $"{greeting} from '{AppDomain.CurrentDomain.FriendlyName}'!"

    interface ITest with
        member this.Test message = this.Test message 

// Construct a path to the current assembly.
let assemblyPath = 
    Environment.CurrentDirectory + "\\" + typeof<MarshalableExample>.Assembly.GetName().Name + ".exe"

let ad = AppDomain.CreateDomain "MyDomain"

let oh =
    ad.CreateInstanceFrom(assemblyPath, "MarshalableExample")

let obj = oh.Unwrap()

// Three ways to use the newly created object, depending on how
// much is known about the type: Late bound, early bound through
// a mutually known interface, or early binding of a known type.
//
obj.GetType().InvokeMember("Test",
    System.Reflection.BindingFlags.InvokeMethod,
    Type.DefaultBinder, obj, [| box "Hello" |])
|> ignore

let it = obj :?> ITest
it.Test "Hi"

let ex = obj :?> MarshalableExample
ex.Test("Goodbye")

(* This example produces the following output:

Hello from 'MyDomain'!
Hi from 'MyDomain'!
Goodbye from 'MyDomain'!
 *)
Public Interface ITest

    Sub Test(ByVal greeting As String)
End Interface

Public Class MarshalableExample 
    Inherits MarshalByRefObject
    Implements ITest

    Shared Sub Main()
    
        ' Construct a path to the current assembly.
        Dim assemblyPath As String = Environment.CurrentDirectory & "\" &
            GetType(MarshalableExample).Assembly.GetName().Name & ".exe"

        Dim ad As AppDomain = AppDomain.CreateDomain("MyDomain")
 
        Dim oh As System.Runtime.Remoting.ObjectHandle = 
            ad.CreateInstanceFrom(assemblyPath, "MarshalableExample")

        Dim obj As Object = oh.Unwrap()


        ' Three ways to use the newly created object, depending on how
        ' much is known about the type: Late bound, early bound through 
        ' a mutually known interface, or early binding of a known type.
        '
        obj.GetType().InvokeMember("Test", 
            System.Reflection.BindingFlags.InvokeMethod, 
            Type.DefaultBinder, obj, New Object() { "Hello" })

        Dim it As ITest = CType(obj, ITest) 
        it.Test("Hi")

        Dim ex As MarshalableExample = CType(obj, MarshalableExample) 
        ex.Test("Goodbye")
    End Sub

    Public Sub Test(ByVal greeting As String) Implements ITest.Test
    
        Console.WriteLine("{0} from '{1}'!", greeting,
            AppDomain.CurrentDomain.FriendlyName)
    End Sub
End Class

' This example produces the following output:
'
'Hello from 'MyDomain'!
'Hi from 'MyDomain'!
'Goodbye from 'MyDomain'!

설명

에 대한 typeName 매개 변수가 없는 생성자가 호출됩니다.

자세한 내용은 Activator.CreateInstanceFrom 메서드를 참조하세요.

경우는 CreateInstanceFrom 메서드는 호출 되는 애플리케이션 도메인 이외의 대상 애플리케이션 도메인에서 인스턴스를 만드는 데, 어셈블리는 대상 애플리케이션 도메인에 로드 됩니다. 그러나 인스턴스 호출 애플리케이션 도메인에서 래핑 해제 된 경우 특정 방식으로 래핑되지 않은 인스턴스를 사용 하 여 호출 애플리케이션 도메인에 로드 될 어셈블리를 발생할 수 있습니다. 예를 들어 instance 래핑 해제된 후 해당 메서드를 늦게 바인딩된 메서드를 호출하기 위해 해당 형식 정보를 요청할 수 있습니다. 어셈블리 호출 애플리케이션 도메인에 로드 되 면 예외가 발생할 수 있습니다.

  • 동일한 어셈블리의 다른 버전 이전에 호출 애플리케이션 도메인에 로드 하는 경우 또는 호출 애플리케이션 도메인의 로드 경로 같은 대상 애플리케이션 도메인, 예외와 다른 경우 MissingMethodException 발생할 수 있습니다.

  • 호출 애플리케이션 도메인 인스턴스 형식의 초기 바인딩 호출 하는 경우 InvalidCastException 인스턴스 캐스팅 하려고 시도 하는 경우에 throw 될 수 있습니다.

추가 정보

적용 대상