Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| //<Snippet1> | |
| using namespace System; | |
| using namespace System::Reflection; | |
| ref class Example | |
| { | |
| internal: | |
| static Assembly^ MyHandler(Object^ source, ResolveEventArgs^ e) | |
| { | |
| Console::WriteLine("Resolving {0}", e->Name); | |
| return Assembly::Load(e->Name); | |
| } | |
| }; | |
| void main() | |
| { | |
| AppDomain^ ad = AppDomain::CreateDomain("Test"); | |
| ad->AssemblyResolve += gcnew ResolveEventHandler(&Example::MyHandler); | |
| try | |
| { | |
| Object^ obj = ad->CreateInstanceAndUnwrap( | |
| "MyAssembly, version=1.2.3.4, culture=neutral, publicKeyToken=null", | |
| "MyType"); | |
| } | |
| catch (Exception^ ex) | |
| { | |
| Console::WriteLine(ex->Message); | |
| } | |
| } | |
| /* This example produces output similar to the following: | |
| Resolving MyAssembly, Version=1.2.3.4, Culture=neutral, PublicKeyToken=null | |
| Resolving MyAssembly, Version=1.2.3.4, Culture=neutral, PublicKeyToken=null | |
| ... | |
| Resolving MyAssembly, Version=1.2.3.4, Culture=neutral, PublicKeyToken=null | |
| Resolving MyAssembly, Version=1.2.3.4, Culture=neutral, PublicKeyToken=null | |
| Process is terminated due to StackOverflowException. | |
| */ | |
| //</Snippet1> |