简体   繁体   English

使用Visual Studio 2010为Windows编写具有自托管WCF项目的胖客户端

[英]Writing a fat-client with self-hosting WCF project for windows using visual studio 2010

I have been researching this for days without success. 我已经研究了好几天没有成功。 I have a visual studio 2010 solution with multiple projects. 我有一个包含多个项目的Visual Studio 2010解决方案。 I am trying to create a fat client in a managed application using self-hosting of a WCF Service Application. 我正在尝试使用WCF服务应用程序的自我托管在托管应用程序中创建胖客户端。 I am moving the application to run on a windows 8 machine that does NOT have visual studio installed. 我将应用程序迁移到没有安装Visual Studio中的Windows 8机器上运行。

On the development machine, all works well until I try to create a ServiceHost for the target machine. 在开发计算机上,一切正常, 直到我尝试为目标计算机创建ServiceHost 为止 When I try to add a ServiceHost , the development machine bombs with: 当我尝试添加ServiceHost时,开发机器会炸弹:

"HTTP could not register URL http://+:24324/DataService.svc/. Your process does not 
have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 
for details)."

Where am I going wrong? 我要去哪里错了? Any help is really appreciated. 任何帮助都非常感谢。 Thanks. 谢谢。

In the client app.config, I have: 在客户端app.config中,我有:

  <client>
  <endpoint address="http://localhost:24324/DataService.svc" 
            binding="basicHttpBinding" 
            bindingConfiguration="BasicHttpBinding_INovaDataService" 
            contract="DataService.INovaDataService" 
            name="BasicHttpBinding_INovaDataService"/>
</client>

In the client Window constructor for the client project, I have: 在客户端项目的客户端Window构造函数中,我具有:

Uri baseAddress = new Uri("http://localhost:24324/DataService.svc");
static ServiceHost host;

 ***Note: In the WCF project itself, "NovaDatServiceClient" is defined  as "NovaDataService"

        host = new ServiceHost(typeof(NovaDataServiceClient), baseAddress);   

        host.Open();    <--*ERROR --HTTP could not register 
          URL http://+:24324/DataService.svc/. Your process does not have access rights to this
         namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details)."}

In the Web.config for the WCF Service Application, I have: 在WCF服务应用程序的Web.config中,我具有:

  <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

My guess is you are running into Port Reservation Permissions issues. 我的猜测是您遇到了“端口保留权限”问题。 The application is trying to reserve the TCP port but the user its running as lacks the rights to do so. 该应用程序正在尝试保留TCP端口,但是用户运行该端口的权限不足。 This link explains the concept and the command lines you need to run to grant your application user port reservation permissions, 该链接说明了授予您的应用程序用户端口保留权限所需运行的概念和命令行,

http://msdn.microsoft.com/en-us/library/ms733768(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/ms733768(v=vs.110).aspx

参见http://msdn.microsoft.com/zh-cn/library/ms733768(v=vs.110).aspx

netsh http add urlacl url=http://+:24324/ user=DOMAIN\user

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM