A blog about SQL Server, SSIS, C# and whatever else I happen to be dealing with in my professional life.

Find ramblings

Monday, May 17, 2010

Visual Studio 2010 upgraded project "could not be resolved because it has an indirect dependency on the framework assembly "System.Web"

I had a perfectly working application at work---Visual Studio 2008, Windows Server 2003, SQL Server 2008. I bring it home to Visual Studio 2010, Windows Server 2008 R2, SQL Server 2008 R2 and SharePoint 2010 (because I'm a masochist). I upgrade the project in place, recompile and it throws this error.
The primary reference "C:\src\Foo\Src\Foo\Foo\bin\Debug\Foo.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5,Profile=Client". To resolve this problem, either remove the reference "C:\src\Foo\Src\Foo\Foo\bin\Debug\Foo.dll" or retarget your application to a framework version which contains "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". FooDriverApp

My solution is a simple one. There are two projects, one is a C# library (Foo) and the other is a tester/driver (FooDriverApp). Foo, which should have the indirect reference to System.Web doesn't. I deleted references, did all sorts of things to try and correct the issue but to no avail. My cursory searches lead to similar scenarios but all of these people were moving from the 3.5 framework to 4.0 I won't have the luxury when I commit my changes back to the repository. My issue ended up being the upgrade process flipped the target framework in my FooDriverApp.csproj from ".NET Framework 3.5" to ".NET Framework 3.5 Client Profile" In the broken version of the .csproj file, this value of <TargetFrameworkProfile>Client</TargetFrameworkProfile> is set to Client. Changing the selector in the project configuration menu to point to the 3.5 results in <TargetFrameworkProfile>
</TargetFrameworkProfile>

References
.NET Framework Client Profile
Troubleshooting .NET Framework Targeting Errors

1 comment:

Clare said...

Just wanted to say thanks for this post. Last year I was using VS 2008, and had no problems, but I've upgraded to 2010, and it has been an absolute nightmare!