NickStrupat / NameOf

Provides strongly typed access to a compile-time string representing the name of a variable, field, property, method, event, enum, or type.
MIT License
20 stars 7 forks source link

Common Language Runtime detected an invalid program/JIT Compiler encountered an internal limitation #10

Closed dittodhole closed 6 years ago

dittodhole commented 8 years ago

I have following example code:

class Program
{
  static void Main(string[] args)
  {
    Console.WriteLine(global::Name.Of<Foo>(arg => arg.Bar));
    Console.ReadLine();
  }
  public class Foo
  {
    public string Bar { get; set; }
  }
}

IntelliSense says that I am using following overload: string Name.Of(Func<Foo,object> fieldOrProperty)

This gives me the following exception:

System.InvalidProgramException was unhandled Message: An unhandled exception of type 'System.InvalidProgramException' occurred in mscorlib.dll Additional information: Common Language Runtime detected an invalid program.

PEVerify gives me following output:

Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440 Copyright (c) Microsoft Corporation. All rights reserved.

[IL]: Error: [ConsoleApplication1.exe : ConsoleApplication1.Program::Main][offset 0x00000031] Stack must be empty on return from a void function. 1 Error(s) Verifying ConsoleApplication1.exe

Following packages are used:

dittodhole commented 6 years ago

not relevant anymore, since the usage of nameof()