0 votes
by (2.5k points)

I have code like so : 

var assembly = Assembly.GetExecutingAssembly();

But when I run this I get : 

Cannot resolve symbol ‘GetExecutingAssembly’ and ‘Assembly’ does not contain a definition for ‘GetExecuringAssembly’

 

1 Answer

0 votes
by (2.5k points)

This is a very specific issue depending on whether you are trying to run in a version of .NET Core less than 2 *or* a .NET Standard library less than 1.5

Essentially, for .NET Core 1 or .NET Standard < 1.5, you have to do something like so :

typeof(<AClassHere>).GetTypeInfo().Assembly

More or less give it a class that you want to get the assembly for. 

But on versions of .NET Core beyond (And .NET Standard beyond 1.5), you can do the standard calls of : 

System.Reflection.Assembly.GetExecutingAssembly();

 

Welcome to .NET Q&A, where you can ask questions and receive answers from other members of the community.
...