I found that targeting application 4.5 can load and run assembly assembler 4.5.2, but I cannot compile such a setting!
Question How can I compile a .NET 4.5 application with reference to a .NET 4.5.2 assembly?
Experiment Details:
- MyLib.csproj - goals 4.5.2
- MyApp.csproj - Goals 4.5, has a link to the MyLib.csproj project
Compilation in Visual Studio or MSBuild fails:
warning MSB3274: The main link "(...) \ MyLib.dll" could not be resolved because it was built as part of ".NETFramework, Version = v4.5.2." This is a higher version than the current target environment is ".NETFramework, Version = v4.5".
error CS0246: Could not find the name or namespace name MyLib (are you missing the using directive or assembly references?)
I tried to compile MyLib separately and reference its DLL, but got the same compilation errors.
However, I managed to start both starts:
- Install both projects in 4.5, compile, copy the result to c: \ test \ MyApp.exe
- Install both projects in 4.5.2, compile, copy the result to c: \ test \ MyLib.dll
- Run MyApp.exe - it works fine!
Background: I am preparing a migration of a large NuGet-managed project from .NET 4.5 to 4.5.2. Announcement
Jonathan
source share