linux-packaging-mono/mono/tests/module-cctor-loader.2.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

24 lines
654 B
C#

using System;
public class Program
{
public static int Main()
{
System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom("module-cctor.exe");
Console.WriteLine("assembly loaded");
Type type = asm.GetType("NS.TestClass", true);
Console.WriteLine("got type 'NS.TestClass'");
System.Reflection.FieldInfo field = type.GetField("TestField");
Console.WriteLine("about to get value of 'TestField'");
Console.WriteLine("got field 'TestField'");
int val = (int)field.GetValue(null);
Console.WriteLine("Value of field: " + val);
if (val == 1)
return 0;
return 1;
}
}