Reputation: 42229
Is it possible to determine at runtime:
Which version of the .NET framework the application is targeting?
If the application is targeting a full or client profile of the framework?
I have tried using Environment.Version
however this produces highly inaccurate results. Equally, I have been unable to find any solutions for determining which profile is being used.
Upvotes: 3
Views: 243
Reputation: 1038710
1) Which version of the .NET framework the application is targeting?
A .NET assembly is targeting a specific version of the framework. But as you know you could have an assembly compiled against .NET 2.0 be loaded into the CLR 4.0. At runtime you could know the CLR version being used to host the application with the Environment.Version property.
2) If the application is targeting a full or client profile of the framework?
The .NET profile is not something that could be determined at runtime. It is only used by Visual Studio to grey out some assemblies in the Add References dialog to prevent you from referencing an assembly that might not be available at runtime. By the way this notion was removed in .NET 4.5.
Upvotes: 4