C# Get Startup Project's Assembly Name
Asked Answered
G

2

6

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

Gloss answered 19/2, 2015 at 19:15 Comment(0)
G
18

To get the name of the startup project, use:

string ProjectName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
Gloss answered 19/2, 2015 at 19:15 Comment(0)
K
0

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
Keeshakeeshond answered 17/11, 2023 at 12:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.