AppDomain.CurrentDomain.ExecuteAssembly (
assembly.Location);
Assert.Fail ("#1");
-#if NET_2_0
} catch (MissingMethodException ex) {
// Entry point not found in assembly '...'
Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#5");
}
-#else
- } catch (COMException ex) {
- // Unspecified error
- Assert.AreEqual (typeof (COMException), ex.GetType (), "#2");
- Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
- Assert.IsNull (ex.InnerException, "#4");
- Assert.IsNotNull (ex.Message, "#5");
- }
-#endif
}
[Test] // ExecuteAssembly (String, Evidence)
assembly.Location,
(Evidence) null);
Assert.Fail ("#1");
-#if NET_2_0
} catch (MissingMethodException ex) {
// Entry point not found in assembly '...'
Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#5");
}
-#else
- } catch (COMException ex) {
- // Unspecified error
- Assert.AreEqual (typeof (COMException), ex.GetType (), "#2");
- Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
- Assert.IsNull (ex.InnerException, "#4");
- Assert.IsNotNull (ex.Message, "#5");
- }
-#endif
}
[Test] // ExecuteAssembly (String, Evidence, String [])
(Evidence) null,
new string [0]);
Assert.Fail ("#1");
-#if NET_2_0
} catch (MissingMethodException ex) {
// Entry point not found in assembly '...'
Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#5");
}
-#else
- } catch (COMException ex) {
- // Unspecified error
- Assert.AreEqual (typeof (COMException), ex.GetType (), "#2");
- Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
- Assert.IsNull (ex.InnerException, "#4");
- Assert.IsNotNull (ex.Message, "#5");
- }
-#endif
}
[Test] // ExecuteAssembly (String, Evidence, String [], Byte [], AssemblyHashAlgorithm)
(byte []) null,
AssemblyHashAlgorithm.SHA1);
Assert.Fail ("#1");
-#if NET_2_0
} catch (MissingMethodException ex) {
// Entry point not found in assembly '...'
Assert.AreEqual (typeof (MissingMethodException), ex.GetType (), "#2");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (assembly.FullName) != -1, "#5");
}
-#else
- } catch (COMException ex) {
- // Unspecified error
- Assert.AreEqual (typeof (COMException), ex.GetType (), "#2");
- Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
- Assert.IsNull (ex.InnerException, "#4");
- Assert.IsNotNull (ex.Message, "#5");
- }
-#endif
}
[Test] // bug #79720
try {
AppDomain.CurrentDomain.Load (aname);
Assert.Fail ("#C9");
-#if NET_2_0
} catch (SecurityException) {
// Invalid assembly public key
}
-#else
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522C";
// we have no public way to get the default appdomain
}
+ static bool resolve_called;
+
+ [Test]
+ public void AssemblyResolveParseError ()
+ {
+ AppDomain currentDomain = AppDomain.CurrentDomain;
+ ResolveEventHandler d = ParseErrorResolve;
+ currentDomain.AssemblyResolve += d;
+ try {
+ resolve_called = false;
+ var a = Assembly.Load ("MyDynamicType, 1.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
+ Assert.Fail ();
+ } catch (FileNotFoundException) {
+ Assert.IsTrue (resolve_called);
+ }
+ currentDomain.AssemblyResolve -= d;
+ }
+
+ static Assembly ParseErrorResolve (object sender, ResolveEventArgs args)
+ {
+ resolve_called = true;
+ return null;
+ }
+
[Test]
public void ReflectionOnlyGetAssemblies ()
{
TestSerialization (tester, typeof (StuffToPick<int>).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int)));
}
+ [Test]
+ public void ShadowCopyTypeGetTypeMissingAssemblyTest ()
+ {
+ ad = CreateShadowCopyAppDomain (tempDir, true);
+ CrossDomainTester tester = CreateCrossDomainTester (ad);
+ tester.AssertLoadMissingAssemblyType ();
+ }
+
private static AppDomain CreateTestDomain (string baseDirectory, bool assemblyResolver)
{
AppDomainSetup setup = new AppDomainSetup ();
return CreateTestDomain (setup, assemblyResolver);
}
+ private static AppDomain CreateShadowCopyAppDomain (string baseDirectory, bool assemblyResolver)
+ {
+ AppDomainSetup setup = new AppDomainSetup ();
+ setup.ApplicationBase = baseDirectory;
+ setup.ApplicationName = "testdomain";
+ setup.ShadowCopyFiles = "true";
+ return CreateTestDomain (setup, assemblyResolver);
+ }
+
private static AppDomain CreateTestDomain (AppDomainSetup setup, bool assemblyResolver)
{
AppDomain ad = AppDomain.CreateDomain ("testdomain",
}
}
- public bool AssertFileLoadException (AssemblyName assemblyRef)
+ public void AssertLoadMissingAssemblyType ()
{
- try {
- AppDomain.CurrentDomain.Load (assemblyRef);
- return false;
- } catch (FileLoadException) {
- return true;
- }
+ Assert.IsNull (Type.GetType ("A.B.C, MissingAssembly"));
}
- public bool AssertFileNotFoundException (AssemblyName assemblyRef)
+ public bool AssertFileLoadException (AssemblyName assemblyRef)
{
try {
AppDomain.CurrentDomain.Load (assemblyRef);
return false;
- } catch (FileNotFoundException) {
+ } catch (FileLoadException) {
return true;
}
}
}
}
-#endif
\ No newline at end of file
+#endif