Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't add a reference to System.Web to my Windows Service application

I'm trying to create a Windows Service in VS2010 but can't seem to add System.Web as reference. When I browse for it and add it manually I get an exclamation mark over the reference. I've tried adding it for other projects and it works fine, just not for a windows service project. Is there a reason for this? I need it to call System.Web.HttpUtility.UrlEncode. Is there alternative method I can use?

like image 226
Christo Avatar asked Jul 20 '10 10:07

Christo


2 Answers

It sounds like your project is configured to target a given framework profile, likely one of the new "Client" distributions. It is telling you that the DLL you've added is not in the targeted profile.

If you look in your project properties, there will be a target framework option under "Application" or possibly "Build".

like image 130
Adam Houldsworth Avatar answered Dec 04 '22 05:12

Adam Houldsworth


One perhbaps rather silly amendmend: Maybe you run in the same problem like I did. I read a lot about changing the target framework. The question for me was: How? In the solution explorer I always hit the top node and "properties" but got a dialog which has only some complile options - nothing more! I want to add the hint that you have to mark your WCF library project first, THEN enter the project properties in VS2010 using the context menu and you will see a totally different properties page: Where you can change the behavior from client project to normal .NET 4.0. Almost took me half an hour...

like image 29
Pilsator Avatar answered Dec 04 '22 06:12

Pilsator