WCF样本服务未运行 [英] WCF-Sample Service not running

查看:71
本文介绍了WCF样本服务未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是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

推荐答案



可能的原因之一似乎是您的控制台进程没有足够的访问权限.因此,我建议您使用管理员权限运行应用程序.

希望对您有所帮助!.

问候,
-Vinayak
Hi,

One of the probable reasons looks like your console process doesnt have the sufficient access rights.Hence i would suggest you to run your application with Administrator previledge it should work.

I hope this helps!.

Regards,
-Vinayak


您是否检查过端口8888是否正在监听其他内容?
Have you checked to see if something else is already listening on port 8888?


这篇关于WCF样本服务未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆