Kashif
Kashif

Reputation: 875

C# Get Startup Project's Assembly Name

Some background: I have a project which collects all the diagnostics (trace source) information from the other projects within my solution. I needed a way to get the main project name so that I could give the dump file a proper unique name.

The issue: I could not find a clear-cut answer on how to obtain the startup project's assembly name until I ran into this blog entry: http://weblog.west-wind.com/posts/2009/Jun/09/Getting-the-Apps-Startup-Assembly-in-WPF-Designer

Upvotes: 6

Views: 7006

Answers (2)

jangix
jangix

Reputation: 99

If your start-up project is a Function App, using the accepted answer would give you the wrong value.

You can use this snipet but beware it only works if you call it from the FunctionApp assembly:

string ProjectName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name

Upvotes: 0

Kashif
Kashif

Reputation: 875

To get the name of the startup project, use:

string ProjectName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;

Upvotes: 18

Related Questions