Lose project reference on build if target frameworks mismatch - by AaronHoffman

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


4
0
Sign in
to vote
ID 530107 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 2/2/2010 8:53:35 AM
Access Restriction Public

Description

If you have a solution with some projects targeting the 3.5 framework and some projects targeting the 4.0 framework, you are able to create references between those projects, even if they are targeting different frameworks.  You are able to develop using those references and step back-and-forth through the code.

During a build however, if the target framework of a referenced project does not match the startup project, the reference is “dropped” and you get a misleading error message saying, “The type or namespace ___ does not exist...  are you missing an assembly reference?”

My thoughts - if this is by design, and you are not able to reference a project that targets a different version of the framework, you should not be allowed to set up the reference in the first place.
Sign in to post a comment.
Posted by J M Baughman on 10/3/2011 at 2:04 PM
And all target frameworks match too.

-John
Posted by J M Baughman on 10/3/2011 at 1:45 PM
I know this issue is marked closed, but I have an example that demonstrates this.

After converting the Growl for Windows solution to Visual Studio 2010 and keeping it at .NET 2.0 (http://www.growlforwindows.com/gfw/default.aspx), touching up the assembly signing issues, and downloading/installing Mono, the Newtonsoft.Json library drops from the build. I've re-added it several times and still get the same result.

I can email the current converted solution to anyone to see if it can be reproduced on someone else's machine.

Current VS2010 installation:

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.0.30319 SP1Rel

Installed Version: Ultimate

Microsoft Office Developer Tools 01019-532-2002102-70424
Microsoft Visual Basic 2010 01019-532-2002102-70424
Microsoft Visual C# 2010 01019-532-2002102-70424
Microsoft Visual C++ 2010 01019-532-2002102-70424
Microsoft Visual F# 2010 01019-532-2002102-70424
Microsoft Visual Studio 2010 Architecture and Modeling Tools 01019-532-2002102-70424
Microsoft Visual Studio 2010 Architecture and Modeling Tools
Microsoft Visual Studio 2010 Code Analysis Spell Checker 01019-532-2002102-70424
Microsoft Visual Studio 2010 Team Explorer 01019-532-2002102-70424
Microsoft Visual Web Developer 2010 01019-532-2002102-70424
Add Reference Dialog Plus! 1.0
AlignAssignments 1.0
AutoBraceComplete 1.0
BraceCompleter 1.0
Collapse Solution 1.0
CommandingImage 1.0
Crystal Reports for .NET Framework 4.0
Document Well 2010 Plus 1.0.10916.0
DotNetRegexTester 1.0
DPack 3.0.11
Format Document 1.0
GhostDoc 2.5.9166.0
InTheBox.MVVMTraining 1.0
Microsoft Visual Studio 2010 Architecture Power Tools 1.0
Microsoft Visual Studio 2010 SharePoint Developer Tools 10.0.40219
Microsoft Visual Studio 2010 Ultimate - ENU Service Pack 1 (KB983509) KB983509
Microsoft.VisualStudio.QuickAccess.Package 1.0
NuGet Package Manager 1.4.20701.9038
OptionsPageImpl 1.0
PowerCommands for Visual Studio 2010 1.0
PowerConsole 1.0
PowerGUIExt 1.0
QuickFind 1.0
tangible T4 Editor 1.0
Theme Manager 1.0
VS10x Selection Popup Package 1.1
VS10x Super Copy Paste Package 1.1
VSCommands 2010 3.7.3.0
Posted by Richa Prasad on 5/6/2011 at 9:35 AM
Please email your solution that reproduces this problem to richap and itodirel AT microsoft.com.
Posted by Jeroen Jansen van Rosendaal on 5/6/2011 at 7:15 AM
I have the same issue, I am working in VS 2010 when using the Build option, my project is breaking. If I copy my changes to my VS2008 project, rebuilding is not a problem.

I am using Debug and Build to test my changes, but the problems occurs when I use Build and then only once in a while. After building the referency in one of my projects say that my XSLTOBJECTS project was build with Framework v4.0.30319 but If I look in this project it is compiled with 3.5.
This has happened to me multipletimes so I stopped using VS 2010 and moved back to VS 2008, wich works fine.

My Gut feeling is that it has something to do with using build while my changed page is still open.

Warning    3    The primary reference "C:\Users\Jeroen\Desktop\Vis Dev 2010 cleaninstall Topsystems V9\XsltObjects\bin\Debug\XsltObjects.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.    AspDotNetStorefrontCore

Is it possible to manualy change the runtime verison in the reference?
Posted by JonVT on 2/18/2010 at 7:40 AM
I beleive I am having the same issue. I have a test project that I can send. How do I send it?
Posted by Microsoft on 2/11/2010 at 1:34 PM
Thanks Aaron, by any means let us know if you still encounter this issue. Referencing 3.5 projects from 4.0 is a completely supported scenario, and it should work. What you can also try if you see the issue again, see if the referenced project referenced anything outside of its targeted framework.

Thanks
-Ion
Visual Studio: Project and Build
Posted by AaronHoffman on 2/3/2010 at 2:24 PM
The 4.0 Project was referencing the 3.5 project. I am unable to reproduce this issue again today.
Posted by Microsoft on 2/3/2010 at 9:43 AM
Thank you for your feedback. The issue is that the 3.5 framework project has a reference to something NOT in the 4.0 Client framework. The workaround is to use the Full 4.0 framework. In order to do this, please go to Project Properties of the project targeting 4.0. If you have a VB project, go to the Compile tab -> Advanced Compile Options... -> Change Target Framework to ".NET Framework 4". For a C# project, the option to change the Target Framework is visible right in the Application tab.

Thanks,
Richa
Posted by Microsoft on 2/3/2010 at 12:00 AM
Thanks for reporting this issue. In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Please give us a demo project to demonstrate this issue so that we can conduct further research.

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Visual Studio Product Team