Reputation: 4096
Is there anyway to reference a .NET4.5 class library in a .NET4.0 WinForm application?
I tried just adding the reference as per usual i.e. Right click on referenced under the .Net4.0 win form app and then add the library in but it gives me the following error
error CS0246: The type or namespace name 'LibTest' could not be found (are you missing a using directive or an assembly reference?)
Both are loaded within the same solution and build otherwise without error
Upvotes: 0
Views: 1066
Reputation: 223237
You cannot. .Net frameworks are not forward compatible. They are backward compatible , you can use .Net framework 3.5 assembly in 4.0, but you can't use 4.5 assembly in .Net framework 4.0
See: Version Compatibility in the .NET Framework
If you have access to source code of 4.5 assembly you can try compiling it with target framework set to 4.0, if there isn't anything used specifically from 4.5 it will compile successfully and could be used with your current project.
Upvotes: 7