我有一个WCF REST服务,它可以从Windows服务(.NET 3.5)中工作。为了更容易构建和调试,我想从控制台运行它。当我这样做时,我正在设置控制台应用程序中的端点。当我创建端点时,它会失败,并显示以下错误: “在服务'System.RuntimeType'实现的合同列表中找不到合同名'IRestService'。”在控制台应用程序中托管WCF REST服务时,发现合同名称错误
我的接口并[的ServiceContract]连接到它有:
namespace RestServiceLibrary
{
[ServiceContract]
public interface IRestService
...
这里是控制台应用程序:
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();
}
}
}
为什么会出现这个错误?我该如何解决它?
请原谅我的问题,但是您有没有在控制台应用程序中引用服务库(.dll)? – CodingGorilla 2010-09-22 20:13:28
没什么太明显的。 :-)我有一个参考。 – pc1oad1etter 2010-09-22 20:19:35
“RestService”的定义是什么? – 2010-09-22 20:19:42