问题描述
我是WCF的新手,并且创建了一个示例WCF服务(创建了控制台应用程序,添加了ServiceModel.dll,已实现ServiceContracts,OperationContracts).当我运行该应用程序时,出现以下异常.
[System.ServiceModel.AddressAccessDeniedException] {"HTTP无法注册URL http://+:8888/Microsoft.ServiceModel.Samples/CalculatorService/.您的进程没有对此命名空间的访问权限(请参阅http://go.microsoft .com/fwlink/?LinkId = 70353了解详情).} System.ServiceModel.AddressAccessDeniedException.
以下是Main()中代码的精妙之处
Hi ,
I am very new to WCF.And I have created a sample WCF service(Created a console Application,Added ServiceModel.dll,Implemented ServiceContracts,OperationContracts).When I am running the application,I am getting the following exception.
[System.ServiceModel.AddressAccessDeniedException] {"HTTP could not register URL http://+:8888/Microsoft.ServiceModel.Samples/CalculatorService/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details)."} System.ServiceModel.AddressAccessDeniedException.
The following is the peice of code in Main()
ServiceHost selfHost = null;
Uri baseAddress = new Uri(http://localhost:8888/Microsoft.ServiceModel.Samples/CalculatorService);
selfHost= new ServiceHost(typeof(CalculatorService), baseAddress);
selfHost.AddServiceEndpoint(typeof(ICalculator),new WSHttpBinding(),CalculatorService);
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);
selfHost.Open();
Console.WriteLine("The service is ready");
Console.ReadKey();
我正在XP OS上运行它.
任何人都可以告诉我如何执行该服务.
谢谢,
Srikrishna
I am running it on XP OS.
Can any one please tell me how can I execute the service.
Thanks,
Srikrishna
推荐答案
这篇关于WCF样本服务未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!