2

I faced a problem after converting a C# project from VS 2005 to VS 2013:

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3268: The primary reference [assembly reference] could not be resolved because it has an indirect dependency on the framework assembly "System.Core" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference [assembly] or retarget your application to a framework version which contains [assembly]

This question has the same issue but the solution does not work for me (use of <SpecificVersion>true</SpecificVersion>)

Result: The project does not compile any more (was no problem under VS 2005)

I don't know how to go on with this, so any hint is welcome...

EDIT
I want to stay with framework 2.0.

EDIT #2
The project references a third-party assembly that targets also 2.0

Community
  • 1
  • 1
joe
  • 8,344
  • 9
  • 54
  • 80
  • Visual Studio has its ways of converting projectfiles to properly retarget never version of .net framework. Open up the project properties inside visual studio and change the Target framework directly under the Application tab. :-) If this does not work then another approach could be to create a new project and add the existing source code to this new project. Then add the references necessary. – Zerratar Nov 26 '14 at 15:37
  • Go to every project you have in this solution and check it's properties, make sure the "Framework" used is the same in every project. Note that 4.5.1 is NOT the same as 4.5 and so on. – Tikkes Nov 26 '14 at 15:37
  • Did you set the project to target the 2.0 Framework? [Instructions here](http://msdn.microsoft.com/en-us/library/bb398202.aspx) – David Nov 26 '14 at 15:38
  • You must avoid obfuscating the assembly names to get an answer. – Hans Passant Nov 26 '14 at 19:36
  • @HansPassant: You're right, I fixed that. It's about System.Core (3.5) – joe Nov 26 '14 at 19:41
  • Well, that's kinda predictable. You always actually had a dependency on 3.5, you just didn't know it. Until MSBuild v12, which looks at *indirect* dependencies to implement the automatic binding redirect feature, and noticed the discrepancy. Targeting a 9 year old version of free software is only ever a good idea to managers. Users of your software don't have that hangup. You can shoot the messenger, but the programmer whose class library you use probably isn't going to be impressed about the change request. – Hans Passant Nov 26 '14 at 20:03
  • @HansPassant: I'm not sure if I understand you correctly. Should I change all the 2.0 projects to 3.5? What's behind the curtain? – joe Nov 26 '14 at 20:22

1 Answers1

0

With a similar issue (same warning message, different assembly), I found a

<bindingRedirect ... />

in the web.config that was associated with the assembly that couldn't be resolved. Removing the bindingRedirect fixed my problem.

BernardV
  • 1,700
  • 20
  • 15