'Assembly' does not contain a definition for 'GetExecutingAssembly' ConsoleUI.DNX Core 5.0

When trying to run the following code in a .NET DNX Core 5.0 project:

var asm = Assembly.GetExecutingAssembly();

I got the following error:

‘Assembly’ does not contain a definition for ‘GetExecutingAssembly’ ConsoleUI.DNX Core 5.0

For DNX 5.0 projects you have to use the following:

var asm = typeof(ATypeInTheAssembly).GetTypeInfo().Assembly;

comments powered by Disqus