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

2

8

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?

Olli answered 20/7, 2010 at 10:59 Comment(2)
Do you have mark the solution for DotNet ClientProfile? Properties of the Project-Node in VS Project-Explorer?Cess
Are you sure you aren't looking for WebServices instead of Windows Service?Eicher
B
16

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".

Bregenz answered 20/7, 2010 at 11:1 Comment(3)
Thanks! I changed the Target framework from ".net framework 4 client profile" to ".net framework 4" and it works fine now.Olli
Thanks man, you saved me so much time! What a useless feature!O
Found mine under Project Properties (right-click project in Solution Explorer, select Properties) > Compile > Advanced Compile OptionsDispleasure
V
1

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...

Vitriolic answered 21/9, 2011 at 8:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.