locked
Misleading warning MSB3258 The primary reference has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0

    Question

  • I have tried to migrate a solution of approx 60 projects from VS2008 to VS2010 (mix of c#, vb and one c++). When I build the solution I receive the 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. If I look at the Total.Felles.UI.dll with Ildasm, it displays:

    // Metadata version: v2.0.50727
    .module extern User32.dll
    .assembly extern System.Windows.Forms
    {
      .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
      .ver 2:0:0:0
    }
    .assembly extern mscorlib
    {
      .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
      .ver 2:0:0:0
    }
    .assembly extern Total.Felles.View.Interface
    {
      .ver 24:0:0:29463
    }
    .assembly extern Total.Oppslag
    {
      .ver 24:0:0:29463
    }
    .assembly extern System
    {
      .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
      .ver 2:0:0:0
    }
    .assembly extern Total.Core
    {
      .ver 24:0:0:29459
    }
    .assembly extern System.Web.Services
    {
      .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
      .ver 2:0:0:0
    }
    .assembly extern Total.Felles.Regneark.Interface
    {
      .ver 24:0:0:29462
    }
    .assembly extern MFCMIFC80
    {
      .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
      .ver 1:0:0:0
    }
    .assembly extern System.Drawing
    {
      .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
      .ver 2:0:0:0
    }
    .assembly extern System.Xml
    {
      .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
      .ver 2:0:0:0
    }
    .assembly extern System.Data
    {
      .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
      .ver 2:0:0:0
    }
    .assembly extern 'Infragistics2.Win.UltraWinGrid.v9.2'
    {
      .publickeytoken = (7D D5 C3 16 3F 2C D0 CB )                         // }...?,..
      .ver 9:2:20092:1003
    }
    .assembly extern 'Infragistics2.Win.Misc.v9.2'
    {
      .publickeytoken = (7D D5 C3 16 3F 2C D0 CB )                         // }...?,..
      .ver 9:2:20092:1003
    }
    .assembly extern 'Infragistics2.Win.UltraWinEditors.v9.2'
    {
      .publickeytoken = (7D D5 C3 16 3F 2C D0 CB )                         // }...?,..
      .ver 9:2:20092:1003
    }
    .assembly extern 'Infragistics2.Win.UltraWinToolbars.v9.2'
    {
      .publickeytoken = (7D D5 C3 16 3F 2C D0 CB )                         // }...?,..
      .ver 9:2:20092:1003
    }
    .assembly extern Total.Altinn.Core
    {
      .ver 24:0:3756:23391
    }
    .assembly extern Total.FellesKomponenter.Interface
    {
      .ver 24:0:0:29458
    }
    .assembly extern Total.Ligningsskjema.Interface
    {
      .ver 24:0:0:29463
    }
    .assembly extern Total.Ligningsskjema.Core
    {
      .ver 24:0:0:29630
    }
    .assembly extern Total.Felles.View
    {
      .ver 24:0:0:29468
    }
    .assembly extern Total.Felles.Regneark
    {
      .ver 24:0:0:29465
    }
    .assembly extern Total.Utilities
    {
      .ver 24:0:0:29458
    }
    .assembly extern 'Infragistics2.Shared.v9.2'
    {
      .publickeytoken = (7D D5 C3 16 3F 2C D0 CB )                         // }...?,..
      .ver 9:2:20092:1003
    }
    .assembly extern 'Infragistics2.Win.v9.2'
    {
      .publickeytoken = (7D D5 C3 16 3F 2C D0 CB )                         // }...?,..
      .ver 9:2:20092:1003
    }
    .assembly extern Total.FellesKomponenter.UI
    {
      .ver 24:0:0:29464
    }
    .assembly extern Xceed.Zip
    {
      .publickeytoken = (BA 83 FF 36 8B 75 63 C6 )                         // ...6.uc.
      .ver 4:1:9373:11490
    }

    The .ver displays .ver 2:0:0:0:0 but the //-section displays // .z\V.4.. Is that an indication of a version 4 dependency?

    I thought that setting the target version in Total.Felles.UI.dll to version 2.0 but stop the build-process if this project was dependent on any 4.0 assembly?

    Any suggestions or troubleshooting tips?

    Thank you in advance.

    RoMo.


    Developer
    Wednesday, April 14, 2010 3:58 PM

All replies

  • The .z\V.4.. is just the ASCII representation of the public token. Even though the "V.4" part looks suggestive, it is not really what it seems: the various dots in the string are just placeholders for unprintable ASCII characters. Specifically, the one between the "V" and the "4" is an ASCII 25 and thus not a dot at all (ASCII 46).

    HTH
    --mc

    Wednesday, April 14, 2010 9:14 PM
  • Ok, but how do I solve this?

    I thought a project (project1) built with a target framework of .net 2.0, would fail if one of it dependencies required a higher framework version. Project 1 builds OK (targeting .net 2.0), but referencing project1 from project2 (also targeting .net 2.0) gives the "warning MSB3258: The primary reference "D:\_Total\Hovedversjon\Managed\Program\Komponenter\Felles\UI\bin\Release\project1.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."

    Changing the target of project2 to .net 4.0 makes the solution build OK.

    Something is causing the project1 to be dependent on a highter framework version than the targeted version. How to find this issue?

    RoMo


    Developer
    Thursday, April 15, 2010 5:26 AM
  • Same issue here, a .NET 2.0 project when updated gets an mscorelib 2.0.0.0 reference AND 4.0.0.0 according to Reflector.  No reference to this in the project file.

     

    R

    Thursday, April 15, 2010 10:03 AM
  • Hello RoMo,

    I use Visual Studio 2010 RTM to convert a 2008 project to 2010. I can compile the converted project correctly without the warning. What VS10 version you are using? Beta, RC or RTM?

    And have you searched in all projects to see if any of them has texts as "<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>"? We can open .csproject in notepad and have a text search.

    And this is a MSBuild issue. Here is the MSBuild forum,

    http://social.msdn.microsoft.com/Forums/en/msbuild/threads/

    Best regards,
    Ji Zhou
    MSDN Subscriber Support in Forum


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, April 21, 2010 6:22 AM
  • Hello Ji Zhou!

    I have tried your suggestion and searched through the *.csproj files in search of v4.0. Only a few test projects have been upgraded to this version, every other project is still version 2.0. I have on your request started a few thread in the MSBuild forum here: http://social.msdn.microsoft.com/Forums/en/msbuild/thread/516647ee-dccf-49ee-959a-00b1fc098eeb

    Thank you for following up on this issue.

    RoMo.


    Developer
    Wednesday, April 21, 2010 8:11 AM