Visual Studio 无法打开托管 WCF 服务的端口
我使用 WCF 服务创建了一个解决方案 VS2010 C#,该库用于获取数据,该服务在解决方案中的控制台应用程序中工作正常。没问题。
对于较旧的项目,我必须在 VS2008 项目(可能稍后在 VS2005)上使用它。然后我启动 VS2010 我得到“WCF Test Client”。此时在VS2008中,我尝试在本地机器上“添加Web引用”...没有结果。
然后我尝试使用 Vs2010 创建一个控制台应用程序来托管它,我这样做了:
Uri baseAddress = new Uri("http://localhost:8080/hello");
using (ServiceHost host = new ServiceHost(typeof(SecurityAccessWCF.WCFSecurityService), baseAddress))
{
// Enable metadata publishing.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(smb);
host.Open();
Console.WriteLine("The service is ready at {0}", baseAddress);
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
// Close the ServiceHost.
host.Close();
}
我在 Open()
上收到错误,我收到此错误“AddressAccessDeniedException - HTTP 无法注册 URL...您的进程没有访问权限”(提供的链接不清楚,我在 Win7 x64 上作为本地管理员并且在域中)
I created a solution VS2010 C# with the WCF service, the library to get data, the service is working fine in a console application in the solution. No problem.
I have to use it on a VS2008 project (and probably later on a VS2005) for the older projects. Then I start VS2010 I get the "WCF Test Client". At this time in the VS2008, I tried to "Add a web reference" on the local machine... no result.
Then I tried to create a console application with Vs2010 to host it, I did this :
Uri baseAddress = new Uri("http://localhost:8080/hello");
using (ServiceHost host = new ServiceHost(typeof(SecurityAccessWCF.WCFSecurityService), baseAddress))
{
// Enable metadata publishing.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(smb);
host.Open();
Console.WriteLine("The service is ready at {0}", baseAddress);
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
// Close the ServiceHost.
host.Close();
}
I get an error on the Open()
, I get this error "AddressAccessDeniedException - HTTP could not register URL... Your process does not have access rights" (the link provided is not clear, I'm on Win7 x64 as local admin and in a domain)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Shift + 鼠标右键单击 Visual Studio 快捷方式并选择以管理员身份运行
这样您就应该能够托管它了。
或者,您可以构建项目并在管理员帐户下以相同的方式运行生成的控制台应用程序。
Shift + Mouse Right Click on Visual Studio shortcut and select Run as administrator
This way you should be able to host it.
Alternately, you could build the project and run the resulting console application the same way under admin account.
这是一个标准错误,意味着您的应用程序无法注册该域。通常这是 vista/windows 7 上的安全问题。以管理员身份登录并运行
netsh http add urlacl url=http://+:80/Localhost user=DOMAIN\user
这里是一篇包含更多信息的 msdn 文章
Thats a standard error meaning your application cant register the domain. Normally this is a problem on vista/windows 7 with security. Log in as administrator and run
netsh http add urlacl url=http://+:80/Localhost user=DOMAIN\user
Here is a msdn article with more information