質問

Attempting to build a Visual Studio 2010 solution with 132 projects which do not use any file references (only project references). When I build the entire solution, I get many build errors like this:

The type or namespace name 'xxxx' does not exist in the namespace '<namespace name>' (are you missing an assembly reference?)

The target framework version for ALL projects in the solution is v3.5.

Hence I started building projects one by one based on the Project Build Order. And on one of the projects (say project A), I get the below info in the Build Output (note the framework version). This project A builds successfully. When I build the next project, say project B, which references project A through a project reference (not file reference), then it throws the above build error. Hence it seems project B is the culprit.

 Compile complete -- 0 errors, 54 warnings
  <ProjectName> -> <filepath>\<filename>.dll
  Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
  Copyright (c) Microsoft Corporation.  All rights reserved.

Details of project B

Solution configuration is Debug.

  • In the References tree of project B, the properties of the project A reference shows

1) "Runtime Version" as v2.0.50727.
2) "Copy local" as True.
3) "Strong Name" as True.
4) "Version" as 1.0.xxxx.xx (as specified in the AssemblyInfo.cs of project A)
5) There is no "Specific Version" key (because it is a project reference)

  • the AssemblyInfo.cs of project B has the following:

1) [assembly: ComVisible(false)]
2) [assembly:Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]
3) [assembly:AssemblyVersion("1.0.xxxx.xx")]
4) [assembly:AssemblyFileVersion("9.0.xxxx.xx")]

  • the project B properties has the following:

1) "Target Framework" as ".NET Framework 3.5"
2) "Output Type" as "Class Library"
3) "Treat warnings as errors" as "None"

My Question(s)

Now, the target framework specified in the properties of ALL my projects is .NET Framework 3.5.

How does the build engine use a GAC Utility of v4.0 when my target framework is v3.5?

Searched all files to see if .NET 4.0 is configured somewhere but could not find it. This seems to be potentially the root cause of the above issue. Or am I missing something else? I believe I have covered the usual suspects.

Also why does the Runtime Version of project A reference in project B say v2.0.50727 when the target framework version for both projects is v3.5?

PS: I tried removing the project reference and adding its file reference instead, still gives the same build error. (This usually used to work before when it was a long name issue but its not in this case).

UPDATE 1:

The build output for the above build error is:

Compile complete -- 13 errors, 0 warnings
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): 
warning MSB3258: The primary reference "<project A reference name>" could not be resolved
because it has an indirect dependency on the .NET Framework assembly 
"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxx" 
which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

UPDATE 2:

The Post-build event command-line for project A has the following which explains why the build uses the GAC Utility of v4.0! Now I need to figure how to get the v3.5 Gacutil in there. My second question still stands though.

cd "$(ProjectDir)"
cd ..\..\..\Bin
gacutil.exe /if "$(TargetPath)"
役に立ちましたか?

解決

To answer your second question:

.Net 3.0 and .Net 3.5 are simply new DLLs that run on the existing CLR 2.0.

There are no runtime versions between 2.0 and 4.0.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top