I am working on a REST WCF project and when I implement the following code, it complains that it can't resolve the WebGet class? What am I missing?
I tried importing the System.ServiceModel.Web namespace but it can't find it even though I referenced it. The "Web" in System.ServiceModel.Web does not register when I register it in a using statement on top of my code.
Basically, what do I need to implement such WCF REST concepts like WebGet, WebInvoke, UriTemplate, etc?
UPDATE: After some feedback and thinking about this a little bit more what I've done, it seems that the DLLs (System.ServiceModel & System.ServiceModel.Web) do not come up via the 'Add Reference' window when I go to add a project reference. When I first started the project, FYI, since these assemblies did not come up at first, I went 'searching' for them, and copied them to a temp folder so I can reference them and thus, I guess I am having the resolve issues. So, now that I am at this point, how can I get my VS to recognize/register these WCF REST DLLs? Thanks!
UPDATE: I believe I am update-to-date on everything: developing on VS 2008 SP1 - I try to download the latest SPs, downloaded the REST Preview 2 Starter Kit, developing against 3.5 Framework, trying to create a WCF REST layer to ultimately be consumed by Silverlight 2 client.
This is what I have:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using UtilityClasses;
using Microsoft.ServiceModel.Web;
using Microsoft.Http;
namespace WcfRestService
{
[ServiceContract]
public interface IRestService
{
[OperationContract(Name = "Add")]
[WebGet(UriTemplate = "/")] // ** can't compile here **
int Add();
}
}
Any advice will be greatly appreciated it.
You need to reference the System.ServiceModel.Web DLL.
Right-click the 'References' folder in your project and choose 'Add Reference...'. Scroll down to System.ServiceModel.Web and click 'OK'.
Just a one thought, you might be targeting your project to .Net Client Profile which exposes limited namespaces. you may need to check the target framework setting at your project properties.
I have faced that with a WCF project not finding System.ServiceModel.Web untill I changed the default framework settings.
HTH
This happened to me too.
I did this:
..and VS found it??
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With