public static void GetTypeByNameTypeloadFailure()
{
RemoteInvokeOptions options = new RemoteInvokeOptions();
RemoteInvoke(() =>
{
string test1 = testtype;
//Loading from the wrong path
Assert.Throws<System.IO.FileNotFoundException>(() =>
Type.GetType(test1,
(aName) => aName.Name == "Foo" ?
Assembly.LoadFrom(@".\TestLoadAssembly.dll") : null,
typeloader,
true
));
//Type specified 'Program2' does not exst
string test2 = "System.Collections.Generic.Dictionary`2[[Program, TestLoadAssembly], [Program2, TestLoadAssembly]]";
Assert.Throws<TypeLoadException>(() => Type.GetType(test2, assemblyloader, typeloader, true));
//Api does not throw
Type t1 = Type.GetType(test2,
assemblyloader,
typeloader,
false //no throw
);
Assert.Null(t1);
return SuccessExitCode;
}, options).Dispose();
}