Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't resolve project reference because of indirect dependency on current target framework

Can someone please translate this into English?

The primary reference
"Microsoft.SQLServer.ManagedDTS, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL"
could not be resolved because it has an indirect dependency on the .NET Framework assembly
"mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
which has a higher version "2.0.3600.0"
than the version "2.0.0.0" in the current target framework.

Is this a problem with the target version of MY PROJECT or a problem between .Net and the SQL Server library I'm trying to use?

I need to target .Net 2.0, but I don't care what sub-level (2.0.3600). Can this be changed? I looked under project properties and didn't see anyway to change the sub-level (only between .Net 2, 3.5, 4, etc.)

What do I need to do to get around this?

like image 382
Pete Alvin Avatar asked Mar 16 '11 21:03

Pete Alvin


1 Answers

I found this issue on another forum and at least it's explained.

Thanks for taking the time to send us this issue.

It appears that the reference is to mscorlib 2.0.3600, which is the Beta 2 of .NET 2.0. Normally this would just work itself out, with the version number of the shipping product being hight, but, in this case, the Beta 2 number is actually higher. Ooopppss...

In order to determine exactly where this reference is coming from, we really need to start with a detailed log. You can get this by executing the following from a Visual Studio command line: msbuild {projectname} /v:d /t:rebuild /fl

This will create an msbuild.log file. Please attach this to the bug so that we can take a look.

As is indicated in the thread, you can use an app.config to redirect. However, this will only work with and executable, and it only band-aid's the real issue, which is that you are using an our of date DLL.

You could also use SpecificVersion=true on the reference. However, this defeats multi-targeting, and is an unsupported advanced scenario. This is basically because once you do this, you may get other errors, and you really have to know what you are doing to get this to work.

We need to determine the actual assembly that is referencing .NET v2.0 Beta 2 so that we can determine how you can get the latest version of the non-Beta2 assembly.

Thanks,

Chuck England Visual Studio Platform Program Manager - MSBuild

There are also two possible options for fixing it posted. One is to update the version of the Microsoft.SQLServer.msxml6_interop.dll in the GAC with a version that has the correct manifest. I'm not sure where you'd get the dll but it's worth reading through the posts on the other site.

The other option is a .config file modification.

Here's what they put for a .config change, but the poster said it worked in an executable, but not in a class library. I hope it helps.

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705">
     <dependentAssembly>
        <assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral"/>
        <bindingRedirect oldVersion="2.0.3600.0" newVersion="2.0.0.0"/>
     </dependentAssembly>
    </assemblyBinding>
</runtime> 
like image 158
David Avatar answered Sep 28 '22 22:09

David