I have a WCF REST service that works from a Windows service (.NET 3.5). To make it easier to build and debug, I would like to run it from a console. When I do this, I am setting up the endpoints in the console app. When I create an endpoint, it fails with this error: "The contract name 'IRestService' could not be found in the list of contracts implemented by the service 'System.RuntimeType'."
My interface DOES have [ServiceContract] attached to it:
namespace RestServiceLibrary
{
[ServiceContract]
public interface IRestService
...
Here is the console app:
namespace RestServiceConsole
{
class Program
{
static void Main(string[] args)
{
WebServiceHost2 webHost = new WebServiceHost2(typeof(RestService), new Uri("http://localhost:8082"));
ServiceEndpoint ep = webHost.AddServiceEndpoint(typeof(IRestService), new WebHttpBinding(), "");
ServiceDebugBehavior stp = webHost.Description.Behaviors.Find<ServiceDebugBehavior>();
stp.HttpHelpPageEnabled = false;
webHost.Open();
Console.WriteLine("Service is up and running");
Console.WriteLine("Press enter to quit ");
Console.ReadLine();
webHost.Close();
}
}
}
Why am I getting this error? How can I fix it?