C# – Does Microsoft.ServiceModel.Web only work in the GAC

c++restservicewcf

I created my first WCF RESTful service with just one GetData, and it works perfectly in localhost, but when I add it to a hosting environment, I get:

Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name 'ServiceModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Does this mean that I need to place the DLL file in the GAC to this work? Shouldn't it work in the BIN folder of my service?

Here is how my service folder looks like:

Service.svc
Service.svc.cs
web.config
BIN
  Microsoft.ServiceModel.Web.dll
  Microsoft.ServiceModel.Web.pdb
  MyService.dll
  MyService.pdb
PROPERTIES
  AssemblyInfo.cs

What can I do in order to make this work?

Best Solution

I had the same problem when I first tried to create a virtual directory directly in IIS 7.5, prior to publishing my RESTful web service to this folder.

The solution for me was to use Visual Studio 2008 (Project Properties / Web tab / "Use IIS Server") to choose the folder, and then the "Create Virtual Directory" button on the same tab to create the virtual directory. Everything then worked OK.