Reputation: 1362
As stated in the title i have that strange behaviour with the subsequent call
Assembly.GetExecutingAssembly().GetName().Name
My exe name is CoreService.exe, with the call above i get different response every time i call it eg :
I get this behaviour working on Windows Server 2012 and only when i start my CoreService as windows service instead of windows process, anybody can explain why of that strange thing ?
Upvotes: 3
Views: 76
Reputation: 8404
Actually Assembly.GetExecutingAssembly().GetName().Name
does not include the extension.
AssemblyName.Name Property
Gets or sets the simple name of the assembly. This is usually, but not necessarily, the file name of the manifest file of the assembly, minus its extension.
Or then you have actually hit the "but not necessarily" part of it... which would be the first I have ever heard of.
If this is the case, and you need to do something about it besides being curious, then you could ensure consistent result.
Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().GetName().Name);
Upvotes: 1