.Net framework version the assembly was created in

string assemblyPath = @”<exe/ dll path>”;

var assembly = Assembly.LoadFrom(assemblyPath);

var customAttributes = assembly.GetCustomAttributesData();

var dotnetFramework = customAttributes.FirstOrDefault(attr => attr.AttributeType.Equals(typeof(TargetFrameworkAttribute)));

var frameworkVersion = string.Empty;

if (null != dotnetFramework)


if (dotnetFramework.ConstructorArguments.Any())


// first argument is the name of the framework.

frameworkVersion = (string)dotnetFramework.ConstructorArguments[0].Value;



Console.WriteLine(“Framework Version: “ + frameworkVersion);


This code will give you the .Net framework version the dll/exe was created in.


I tested it for 4.5, 4.6.1 , 4.5.2 and gives the correct info.



Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s