C# .NET DLL Won't Build Because of System.Web conflicts
I'm having an issue with my Class Library in Visual Studio C# Express 2010. The project is configured with a target framework of the .NET 4.0 (not Client Profile).
In my class library, I have added a reference to System.Web to get the URL Encoding to wor开发者_高级运维k for my oAuth library.
When building the DLL, and the associated testing application, I get the following error:
Error 1 The type or namespace name 'TwitterAPI' could not be found (are you missing a using directive or an assembly reference?) C:\Users\sammarks\Documents\Programming\Twitter.NET\Tester\Program.cs 5 7 Tester
And, I get the follow warning message:
Warning 2 The referenced assembly "C:\Users\sammarks\Documents\Programming\Twitter.NET\TwitterAPI\bin\Release\TwitterAPI.dll" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. Tester
I'm not sure why it does this, but that's why I came here. I've tried retargeting the class library to 3.5, but that did nothing but mess it up further.
I've also tried to re-add the System.Web to the references, but that didn't help either.
Any suggestions?
Target the full .NET Framework 4.0 for access to System.Web (not the Client Profile):
- .NET Framework Client Profile assemblies
Might sound silly, but have you tried restarting Visual Studio ?
It sometimes tends to miss a reference or two.
It looks like your class library has a reference to the client profile, while your test executable is referencing the non-client profile. I am gleaning this from the warning:
...currently targeted framework ".NETFramework,Version=v4.0,Profile=Client ...
精彩评论