Created
September 8, 2017 13:47
-
-
Save EgorBo/6bec05de44d6705332f9f15ae3fca8fe to your computer and use it in GitHub Desktop.
GlobalField bug.cs
This file contains hidden or 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
using System; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
namespace MyConsoleHelper | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ModuleBuilder module = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.Run).DefineDynamicModule("Module"); | |
FieldBuilder fieldBuilder = module.DefineInitializedData("GlobalField", new byte[4], FieldAttributes.Public); | |
module.CreateGlobalFunctions(); | |
FieldInfo globalField = module.GetField(fieldBuilder.Name); | |
Expression.Bind(globalField, Expression.Default(globalField.FieldType)); | |
//netcore: OK | |
//mono: | |
/* | |
Unhandled Exception: | |
System.NotImplementedException: Derived classes must implement it | |
at System.Reflection.Module.GetField (System.String name, System.Reflection.BindingFlags bindingAttr) [0x00005] in <b99f966ff3e440589b4fb19c69468323>:0 | |
at System.Reflection.Emit.ModuleBuilder.GetField (System.String name, System.Reflection.BindingFlags bindingAttr) [0x00000] in <b99f966ff3e440589b4fb19c69468323>:0 | |
at System.Reflection.Module.GetField (System.String name) [0x00000] in <b99f966ff3e440589b4fb19c69468323>:0 | |
at MyConsoleHelper.Program.Main (System.String[] args) [0x0003b] in <32af4da4277b489cafd7a5f099ebf4b5>:0 | |
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotImplementedException: Derived classes must implement it | |
at System.Reflection.Module.GetField (System.String name, System.Reflection.BindingFlags bindingAttr) [0x00005] in <b99f966ff3e440589b4fb19c69468323>:0 | |
at System.Reflection.Emit.ModuleBuilder.GetField (System.String name, System.Reflection.BindingFlags bindingAttr) [0x00000] in <b99f966ff3e440589b4fb19c69468323>:0 | |
at System.Reflection.Module.GetField (System.String name) [0x00000] in <b99f966ff3e440589b4fb19c69468323>:0 | |
at MyConsoleHelper.Program.Main (System.String[] args) [0x0003b] in <32af4da4277b489cafd7a5f099ebf4b5>:0 | |
*/ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment