Reputation: 6016
I have a solution of (C#) .NET 4 Client Profile projects in Visual Studio 2012. Today I tried to add another project, also targeted at .NET 4 Client Profile. My new project needs to reference a number of other class libraries in my solution, but it fails to do so for each one with this error:
The currently targeted framework ".NETFramework,Version=v4.0,Profile=Client" does not include "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which the referenced assembly "log4net" depends on. This caused the referenced assembly to not resolve. To fix this, either (1) change the targeted framework for this project, or (2) remove the referenced assembly from the project.
None of the projects I am referencing depend on System.Web
, and they are all targeted at .NET 4 Client Profile. In fact, the error pasted above is for log4net
which certainly doesn't depend on System.Web
.
I have cleaned and rebuilt my entire solution multiple times, and have restarted Visual Studio with no effect. Any ideas as to how I can get my project to build?
One piece of probably useless information that I'll throw out there: When I created my class library project, it targeted to .NET 4.5 automatically, and I later changed it to .NET 4 Client Profile.
Upvotes: 1
Views: 3024
Reputation: 1914
For me this is what worked: right click your project in the solution explorer -> unload project - > then right click the project and edit yourprojectname.csproj remove the "Client" value in the node TargetFrameworkProfile, so it should look like this:
<TargetFrameworkProfile></TargetFrameworkProfile>
Reload your project then rebuild, and that should solve the problem
Upvotes: 0
Reputation: 6016
Found the problem.
I installed log4net with NuGet while my project was still targeted at .NET 4.5. This caused my packages.config file to be written:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.0" targetFramework="net45" />
</packages>
Uninstalling and reinstalling all of my packages from NuGet after changing my target framework version caused the packages.config to be deleted, and rewritten as:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.0" targetFramework="net40-Client" />
</packages>
And now it works.
Upvotes: 0
Reputation: 25521
log4net does depend on System.Web. You may not be using that namespace, but, that library requires it. There is another question that talks about how you could remove it if you're willing to build the project yourself. You could also change the application target as noted in a different question.
Upvotes: 1