问题
I have a MVC 3 application that targets .net 4.0 It has a dozen or so projects also targeting .net 4.0
I have created a new project for the solution targeting .net 4.5 that uses reflection (there are a couple of nice bits of functionality in 4.5 that I want to use). When I try to compile I get an error saying that the 'type or namespace (new 4.5 proj) could not be found, are you missing a directive or an assembly reference'.
Is it possible to have a reference to an assembly targeting .net 4.5 in a project that targets 4.0?
回答1:
Is it possible to have a reference to an assembly targeting .net 4.5 in a project that targets 4.0?
No. It shouldn't be. There could be some features that are used in .Net 4.5 assembly which are not part of .Net 4.0, In that particular case, it should fail.
回答2:
I guess you could just set your project to .net 4.5, but if you would like to keep it as 4.0, take a look at this link might help you
回答3:
Yes, it is possible. Just open the .csproj file for the .Net 4.0 assembly giving the assembly load error in a text editor and set this for the .Net 4.5 assembly reference:
<SpecificVersion>True</SpecificVersion>
来源:https://stackoverflow.com/questions/18700360/is-it-possible-to-reference-an-assembly-that-targets-net-4-5-in-a-project-that