Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Environment:
VS2010 and .Net 3.5 (SP1 installed and VS2008)

I have a solution with 3 small projects;
1.vcxproj (output: 1.lib) - unmanaged C++ code (platform toolset: v100, framework: v3.5)
2.vcxproj (input: 1.lib & output: 2.dll) - managed C++ code (platform toolset: v100)
3.csproj (input: 2.dll & output: 3.dll) (framework: v3.5)

The first 2 projects were compiled successfully but when we compile 3.csproj, we received a warning;

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.Targets(1578,5): warning MSB3258: The primary reference "F:\Test\Proj2\2.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version"2.0.0.0" in the current target framework. [f:\Test\Proj3\3.csproj]

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.Targets(1578,5): warning MSB3258: The primary reference "F:\Test\Proj2\2.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "10.0.0.0" than the version "8.0.0.0" in the current target framework. [f:\Test\Proj3\3.csproj]

I have tried the suggestions from the internet but they are not working. Would you know what my problem is?

Thanks in advance.

Additional information - in GAC, I see these;

F:\bin>gacutil /l mscorlib
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.

The Global Assembly Cache contains the following assemblies:
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=AMD64
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=AMD64
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86

Number of items = 4

====================================
F:\bin>gacutil /l Microsoft.VisualC
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.

The Global Assembly Cache contains the following assemblies:
Microsoft.VisualC, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

Number of items = 2
Posted

1 solution

It's telling you that your Proj2 was written against .NET 4.0 or .NET 4.5 and you're trying to use that .DLL in a .NET 3.5 project.

.NET 4.0 and 4.5 both use the .NET 4.0 Common Language Runtime. .NET 2.0, 3.0 and 3.5 all use the .NET 2.0 CLR.

You cannot mix different CLR versions in the same process. Retarget your Proj2 project to compile against .NET 3.5 and you won't get this warning.
 
Share this answer
 
Comments
Jhun_A 16-Oct-13 0:00am    
I see, yes this could be a possible scenario although when I checked my setting;

2.vcxproj is already targetting .Net 3.5, the line below is found under the Globals section of the project (I removed the "<" and ">")

targetframeworkversion v3.5 targetframeworkversion

So, to confirm, the VS2010 can target .Net 3.5 if I have the correct settings on the projects?
Dave Kreskowiak 16-Oct-13 7:36am    
Whoops, may bad. It's Project 3 that is the dependency on .NET 4.x, not 2.
Jhun_A 16-Oct-13 7:39am    
project 3 also has .Net 3.5 as its target framework

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900