'System.Reflection.Assembly.GetExecutingAssembly() always returns 0.0.0.0

I have modified my assemblyinfo.cs with this:

[assembly: AssemblyVersion("1.0.*")]

and on the _layout.cshtml I put this so I can recognize in which build I am testing:

 @System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()

it always prints 0.0.0.0

When I go to the bin folder and check the dll properties, version says 1.0.343.2323 so I dont get it?



Solution 1:[1]

Looks like the executing assembly is not the one you've compiled, but a dynamic assembly created by IIS.

Try using

typeof(Your_Type_From_NonWeb_Assembly).Assembly.GetName().Version.ToString()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1