AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly2";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- AppDomain.CurrentDomain.Evidence);
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, Evidence)
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly3";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- Path.GetTempPath ());
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String)
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly4";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- Path.GetTempPath (),
- AppDomain.CurrentDomain.Evidence);
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence)
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly5";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- (PermissionSet) null,
- (PermissionSet) null,
- (PermissionSet) null);
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, PermissionSet, PermissionSet, PermissionSet)
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly6";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- AppDomain.CurrentDomain.Evidence,
- (PermissionSet) null,
- (PermissionSet) null,
- (PermissionSet) null);
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, Evidence, PermissionSet, PermissionSet, PermissionSet)
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly7";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- Path.GetTempPath (),
- (PermissionSet) null,
- (PermissionSet) null,
- (PermissionSet) null);
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, PermissionSet, PermissionSet, PermissionSet)
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly8";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- Path.GetTempPath (),
- AppDomain.CurrentDomain.Evidence,
- (PermissionSet) null,
- (PermissionSet) null,
- (PermissionSet) null);
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet)
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly9";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- Path.GetTempPath (),
- AppDomain.CurrentDomain.Evidence,
- (PermissionSet) null,
- (PermissionSet) null,
- (PermissionSet) null,
- true);
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean)
}
}
-#if NET_2_0
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean, IEnumerable<CustomAttributeBuilder>)
public void DefineDynamicAssembly10_Access_Invalid ()
{
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly10";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- Path.GetTempPath (),
- AppDomain.CurrentDomain.Evidence,
- (PermissionSet) null,
- (PermissionSet) null,
- (PermissionSet) null,
- true,
- new List<CustomAttributeBuilder> ());
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName, AssemblyBuilderAccess, String, Evidence, PermissionSet, PermissionSet, PermissionSet, Boolean, IEnumerable<CustomAttributeBuilder>)
AssemblyName name = new AssemblyName ();
name.Name = "DefineDynamicAssembly11";
-#if NET_2_0
try {
AppDomain.CurrentDomain.DefineDynamicAssembly (
name, AssemblyBuilderAccess.Run |
Assert.IsNotNull (ex.ParamName, "#6");
Assert.AreEqual ("access", ex.ParamName, "#7");
}
-#else
- AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (
- name, AssemblyBuilderAccess.Run |
- (AssemblyBuilderAccess) 666,
- new List<CustomAttributeBuilder> ());
- Assert.IsNotNull (ab, "#1");
-#endif
}
[Test] // DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess, IEnumerable<CustomAttributeBuilder>)
Assert.IsTrue (ex.Message.IndexOf (typeof (object).Assembly.FullName) != -1, "#5");
}
}
-#endif
[Test]
public void SetThreadPrincipal ()
aname = new AssemblyName ();
aname.Name = "bug79522A";
aname.CodeBase = assemblyFile;
-#if NET_2_0
AppDomain.CurrentDomain.Load (aname);
-#else
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#A3");
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522A";
aname.CodeBase = assemblyFile;
aname.Version = new Version (2, 5);
-#if NET_2_0
// the version number is not considered when comparing the manifest
// of the assembly found using codebase
AppDomain.CurrentDomain.Load (aname);
-#else
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#A4");
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522A";
aname.CodeBase = assemblyFile;
aname.Version = new Version (2, 4, 1);
-#if NET_2_0
// the version number is not considered when comparing the manifest
// of the assembly found using codebase
AppDomain.CurrentDomain.Load (aname);
-#else
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#A5");
- } catch (FileLoadException) {
- }
-#endif
// if version is set, then culture must also be set
aname = new AssemblyName ();
aname.Name = "bug79522A";
aname.CodeBase = assemblyFile;
aname.Version = new Version (2, 4);
-#if NET_2_0
AppDomain.CurrentDomain.Load (aname);
-#else
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#A6");
- } catch (FileLoadException) {
- }
-#endif
// version number does not need to be set
aname = new AssemblyName ();
aname = new AssemblyName ();
aname.Name = "bug79522B";
aname.CodeBase = assemblyFile;
-#if NET_2_0
// the version number is not considered when comparing the manifest
// of the assembly found using codebase
AppDomain.CurrentDomain.Load (aname);
-#else
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#B3");
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522B";
aname.CodeBase = assemblyFile;
aname.Version = new Version (5, 5);
-#if NET_2_0
// the version number is not considered when comparing the manifest
// of the assembly found using codebase
AppDomain.CurrentDomain.Load (aname);
-#else
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#B3");
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522B";
aname.CodeBase = assemblyFile;
aname.Version = new Version (2, 4, 1);
-#if NET_2_0
AppDomain.CurrentDomain.Load (aname);
-#else
- // when the loaded assembly has a specific culture, then that
- // culture must be set if you set the Version on the aname
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#B4");
- } catch (FileLoadException) {
- }
-#endif
// version does not need to be set
aname = new AssemblyName ();
aname = new AssemblyName ();
aname.Name = "bug79522C";
aname.CodeBase = assemblyFile;
-#if NET_2_0
AppDomain.CurrentDomain.Load (aname);
-#else
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#C3");
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522C";
aname.Name = "bug79522C";
aname.CodeBase = assemblyFile;
aname.Version = new Version (2, 4);
-#if NET_2_0
AppDomain.CurrentDomain.Load (aname);
-#else
- // when the loaded assembly has a specific culture/publickey,
- // then that culture/publickey must be set if you set the
- // Version on the aname
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#C4");
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522C";
aname.CodeBase = assemblyFile;
aname.CultureInfo = new CultureInfo ("nl-BE");
aname.Version = new Version (2, 4);
-#if NET_2_0
AppDomain.CurrentDomain.Load (aname);
-#else
- // if loaded assembly is signed, then the public key must be set
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#C5");
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522C";
aname.CodeBase = assemblyFile;
aname.CultureInfo = new CultureInfo ("nl-BE");
aname.SetPublicKey (publicKey);
-#if NET_2_0
AppDomain.CurrentDomain.Load (aname);
-#else
- // if public key is set, then version must be set
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#C6");
- } catch (FileLoadException) {
- }
-#endif
aname = new AssemblyName ();
aname.Name = "bug79522C";
aname.CodeBase = assemblyFile;
aname.CultureInfo = new CultureInfo ("nl-BE");
-#if NET_2_0
AppDomain.CurrentDomain.Load (aname);
-#else
- try {
- AppDomain.CurrentDomain.Load (aname);
- Assert.Fail ("#C7");
- } catch (FileLoadException) {
- }
-#endif
// if culture and version are set, then the version must match
aname = new AssemblyName ();
AppDomain.CurrentDomain.SetData (null, "data");
}
-#if NET_2_0
[Test]
public void ApplyPolicy ()
{
{
return Assembly.ReflectionOnlyLoad(args.Name);
}
-#endif
+
public class StuffToPick
{
public event Action Event;
public int Field;
public void GenericMethod<T> () {}
+
+ public void Dummy ()
+ {
+ Event += delegate {};
+ }
}
public class StuffToPick<T>
public int Property { get; set; }
public event Action Event;
public int Field;
- public void GenericMethod<T> () {}
+ public void GenericMethod<U> () {}
+
+ public void Dummy ()
+ {
+ Event += delegate {};
+ }
}
static void TestSerialization (CrossDomainTester tester, object o)
}
[Test] //BXC #12611
- [Category ("NotWorking")] // Serialization can't handle generic methods
public void GenericReflectionObjectsAreSerializableTest ()
{
ad = CreateTestDomain (tempDir, true);
tester.AssertLoadMissingAssemblyType ();
}
+ [Test]
+ public void ShadowCopyDontChangeAssemblyCodeBase ()
+ {
+ var setup = new AppDomainSetup ();
+ setup.ApplicationBase = tempDir;
+ setup.ApplicationName = "testdomain";
+ setup.ShadowCopyFiles = "true";
+ var ad = CreateTestDomain (setup, true);
+
+ string assemblyFile = Path.Combine (tempDir, "TestAssembly.dll");
+ AssemblyName aname = new AssemblyName ();
+ aname.Name = "TestAssembly";
+ GenerateAssembly (aname, assemblyFile);
+
+ var tester = CreateCrossDomainTester (ad);
+ var codeBaseFromShadowCopy = tester.LoadAndGetName ("TestAssembly");
+ var expected = Assembly.LoadFrom (Path.Combine (tempDir, "TestAssembly.dll"));
+ Assert.AreEqual (expected.GetName ().CodeBase, codeBaseFromShadowCopy);
+ }
+
private static AppDomain CreateTestDomain (string baseDirectory, bool assemblyResolver)
{
AppDomainSetup setup = new AppDomainSetup ();
{
return obj;
}
+
+ public string LoadAndGetName (string assemblyName)
+ {
+ var assembly = Assembly.Load (assemblyName);
+ return assembly.GetName ().CodeBase;
+ }
}
[Serializable ()]