-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
svn path=/trunk/mono/; revision=71188
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
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; | |||
} | |||
} | |||
|
|||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
.assembly TestDll { } | |||
.assembly extern mscorlib { } | |||
|
|||
.method assembly specialname rtspecialname static | |||
void .cctor() cil managed | |||
{ | |||
ldc.i4 1 | |||
stsfld int32 NS.TestClass::TestField | |||
ldstr "Module contructor executed" | |||
call void [mscorlib]System.Console::WriteLine(string) | |||
ret | |||
} | |||
|
|||
.namespace NS | |||
{ | |||
.class public TestClass extends [mscorlib]System.Object | |||
{ | |||
.field public static int32 TestField | |||
|
|||
.method public static void TestMethod() cil managed | |||
{ | |||
ldstr "TestMethod executed" | |||
call void [mscorlib]System.Console::WriteLine(string) | |||
ret | |||
} | |||
.method public static void Main() cil managed | |||
{ | |||
.entrypoint | |||
ret | |||
} | |||
} | |||
} |