views:

146

answers:

4

How can I programmatically (C#) obtain the version of Visual Studio my application was built with?

+6  A: 

Looking at the compiled assembly there is no way you can differentiate between one built with a command line csc or built with visual studio.

Otávio Décio
Right, Visual Studio itself doesn't compile your program, the C# compiler does. And I have no reason to believe the C# compiler embeds its own version number in the output.
Qwertie
A: 

System.Environment.Version gives you the .NET version you are using...I know it's not what you asked for, but something interesting.

Aaron
A: 

You can build your application with other tools such as MSBuild. In some larger working environments the F5 build and run is disabled and have much more complext build systems.

I don't think it is possible to tell which version other than the .net version which is requiured.

Coding Monkey
+1  A: 

You could add a new appSettings key in your web.config, and then manually update the value as developers take over in the future.

The .csproj file contains meta data that you could query from.

Jon
how do you do that?