Home » .Net FrameworkRSS

warning MSB3258: The primary reference has an indirect dependency which has a higher version "4.0.0.

Hello!

I have a VS2008 solution containing approx 60 projects (mostly c#, but a few vb and one c++ projects). When converting to VS2010 and trying to build i receive an warning/error message:

warning MSB3258: The primary reference "D:\_Total\Hovedversjon\Managed\Program\Komponenter\Felles\UI\bin\Release\Total.Felles.UI.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. On separate lines I also get the same warning for System, System.Configuration, System.Xml, System.Security, System.Data.SqlXml.

What puzzles me is that the project Total.Felles.UI.dll is built within the same solution with the target framework set to .Net Framework 2.0. And when trying to build the Total.Felles.UI.dll separately by right clicking and build it succeeds with a target for .net 2.0. The compiler/build should have failed if the target was set to .net 2.0 and the projects referenced a assembly requering a higher .net version shouldn't it?

It is worth mentioning that the Total.Felles.UI.dll includes a reference to an externally built assembly RichTextBoxExtended.dll which is listet with a runtime version v1.1.4322.

I have searched through all *.csproj files and there is no references to <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>, except for a few projects containing testprojects. These test-projects have no projects dependent on them. Every other porjects has a <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>.

Any suggestions for how to troubleshoot further?

Thank you in advance.
RoMo.

(PS! This is a 'repost' from the c# compiler forum, as I was recommended by Ji Zhou (MSDN Subscriber Support in Forum) that this was a Msbuild issue, and not a C# issue).

 

 

7 Answers Found

 

Answer 1

Hi,

If you set MSBuild Project Build Output Verbosity to "Detailed" on Tools\Options\Projects and Solutions\Build And Run page, and then rebuild Total.Felles.UI.dll, and then examine the build log, do you see "mscorlib, Version=4.0.0.0,..." anywhere in the log?  It might show up in ResolveAssemblyReference target or you could check csc (or vbc if it's VB) compiler command lines in the log.

Also the same excersise can be done with the project where you see MSB3258 warning.

Cheers,
Ilya

 

Answer 2

I've run into the same problem with Mono.Cecil. It has been absolutely infuriating. What is weird is that out of about 14 projects, VS2010 said that Mono.Cecil didn't need a conversion to load in VS2010. According to the TargetFramework property on the project, it was supposed to compile against 2.0, but sure enough when you look at the dll in reflector, it was referencing mscorlib 2.0 AND 4.0. If right clicked on Mono.Cecil in the references of another project - like Mono.Cecil.Pdb - and looked at the properties it said Mono.Cecil was compiled against v4.0. 

As a last resort, I created a new class library from scratch, then copied the first <PropertyGroup> data to my mono.cecil.csproj and now it seems to work correctly - although I had to make sure I was still signing my assembly.

Going through all that for 60 projects would have to be a pain, but hopefully this ridiculous issue is only happening on one or two of your projects.

 

Answer 3

Hi Romo,

Are Ilya and Viggity's repy helpful? Please let me know what I can help. Thanks.

 

Regards,

Nancy Shao [MSFT]
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg @ microsoft.com

 

Answer 4

I am having the same problem, and it appears to have something to do with MFCMIFC80. The reference is indirect because I am referencing an assembly which uses MFCMIFC80 but which does not appear to require a specific version. As a result, MFCMIFC80 is coming from the .NET version 4.0 stuff, and that in turn references mscorlib v4.0.0.0.

So it seems that all your references, all the way down the chain, need to use some strong versioning. Or does this only apply to assemblies which use managed C++?

I will try to do some more checking on this.

 

Answer 5

Hi,

To unblock you, please see description for SpecificVersion metadata on Reference items on http://msdn.microsoft.com/en-us/library/9ad3f294.aspx (ResolveAssemblyReference task help).  It says: "When a project targets a .NET Framework version and references an assembly compiled for a higher .NET Framework version, the reference resolves only if it has SpecificVersion set to true" So you could try to add this metadata to the references in the project. You'd have to edit the project file as this property is not exposed in UI.  However, this method has some implictions.

When your app depends (may be indirectly) on an assembly that references a higher framework, you may have some troubles with deployment.  You'll have to either make sure that all required frameworks are there on the target machine, or that the higher, and possibly not-yet-installed, framework references are not used if the framework is not installed.

Having references to both 2.0 and 4.0 is not a good thing, but not necessarily a bug. 

Cheers,
Ilya

 

Answer 6

I tried setting up a little test app with a DLL built in VS2005 targeting .NET v2 being referenced by a project built using VS2010 targeting .NET v2, v3.5, v4 . The v2 DLL references MFCMIFC80.DLL version 1.0.0.0.

The VS2010 project only compiles when targeting .NET v4.

I have tried setting the SpecificVersion flag to true when building the VS2005 DLL, but it seems to have no effect. VS2010 always tries to use V4.0_1.0.0 of MFCMIFC80 when resolving the secondary references and gives an error unless it is targeting .NET v4.

Our problem is not that we are referencing an assembly compiled for a higher version. Our problem is that we are trying to target the *same* version as the assembly we are referencing, and that just doesn't seem to work.

 

I would be happy to send you the test apps...

I have used the REFLECTOR tool to look at this, and it appears that there is some confusion with MFCMIFC80.DLL. When I drill down into it, it appears to be version 1.0.0 but it also appears to be referencing mscorlib 4.0.0. When I try to use the "Go To Assembly" command it shows my version 4 of MFCMIFC80.

Something isn't right here and I'll be darned if I can tell what it is.

It's almost like the GAC is getting confused and is not able to find the files in c:\windows\assembly so it's getting the ones out of c:\windows\microsoft.net\assembly.

UPDATE: I tried copying the correct version of MFCMIFC80.DLL into the bin directory of my VS2005 project. Curiously, it now compiles and runs, and the Output window says that it has been loaded from C:\WINDOWS\assembly\xxxxx, which is the correct location. There just seems to be some problem at compile-time getting VS2010 to resolve to the correct version.

 

Answer 7

I am also encountering the same problem (or similar), a sample is:

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "3.0.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" 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.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" 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.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System, 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.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System, 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.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "3.0.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "3.0.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Xml, 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.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Xml, 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.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "3.5.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "3.5.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "3.5.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "3.5.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.WebServices, Version=1.2.68.438, Culture=neutral, PublicKeyToken=c048ea67f40f02b7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" which has a higher version "4.0.0.0" than the version "3.5.0.0" in the current target framework.

c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "Maelstrom.System, Version=1.2.68.438, Culture=neutral, PublicKeyToken=da441e880310e7d7, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

 

 

Hi,

If you set MSBuild Project Build Output Verbosity to "Detailed" on Tools\Options\Projects and Solutions\Build And Run page, and then rebuild Total.Felles.UI.dll, and then examine the build log, do you see "mscorlib, Version=4.0.0.0,..." anywhere in the log?  It might show up in ResolveAssemblyReference target or you could check csc (or vbc if it's VB) compiler command lines in the log.

Also the same excersise can be done with the project where you see MSB3258 warning.

Cheers,
Ilya

I have tried this and I DO see mscorelib, Version=4.0.0.0 which it says (if I read it properly) that it is being used instead of mscorelib, Version=2.0.0.0 because it is a later version.

Changing Targeted version, and playing with SpecificVersion has had no apparent effect.

 

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter