C# 在不同的应用程序中使用相同的根基址

C# 在不同的应用程序中使用相同的根基址,c#,web-services,wcf,C#,Web Services,Wcf,我正在尝试创建两个独立的端点,它们托管在两个独立的Windows服务中。 http://mydevice/thisresource http://mydevice/thatresource 第一个服务的My app.config文件如下所示: <service behaviorConfiguration="WebHttpServiceBehavior" name="MyService1"> <endpoint address="" behaviorConfiguration

我正在尝试创建两个独立的端点,它们托管在两个独立的Windows服务中。 http://mydevice/thisresource

http://mydevice/thatresource

第一个服务的My app.config文件如下所示:

<service behaviorConfiguration="WebHttpServiceBehavior" name="MyService1">
  <endpoint address="" behaviorConfiguration="WebEndpointBehavior"
      binding="webHttpBinding" bindingConfiguration="StreamingWebHttpBinding"
      name="WebEndpoint" contract=MyContract" />
  <host>
    <baseAddresses>
      <add baseAddress="http://localhost" />
    </baseAddresses>
  </host>
</service>
<service behaviorConfiguration="WebHttpServiceBehavior" name="MyService2">
  <endpoint address="" behaviorConfiguration="WebEndpointBehavior"
      binding="webHttpBinding" bindingConfiguration="StreamingWebHttpBinding"
      name="WebEndpoint" contract=MyContract2" />
  <host>
    <baseAddresses>
      <add baseAddress="http://localhost" />
    </baseAddresses>
  </host>
</service>
第二个服务的My app.config文件如下所示:

<service behaviorConfiguration="WebHttpServiceBehavior" name="MyService1">
  <endpoint address="" behaviorConfiguration="WebEndpointBehavior"
      binding="webHttpBinding" bindingConfiguration="StreamingWebHttpBinding"
      name="WebEndpoint" contract=MyContract" />
  <host>
    <baseAddresses>
      <add baseAddress="http://localhost" />
    </baseAddresses>
  </host>
</service>
<service behaviorConfiguration="WebHttpServiceBehavior" name="MyService2">
  <endpoint address="" behaviorConfiguration="WebEndpointBehavior"
      binding="webHttpBinding" bindingConfiguration="StreamingWebHttpBinding"
      name="WebEndpoint" contract=MyContract2" />
  <host>
    <baseAddresses>
      <add baseAddress="http://localhost" />
    </baseAddresses>
  </host>
</service>
这段代码将在一个独立的Windows设备上运行,外界将对此进行攻击。我真的不想使用URI命名约定,比如,因为,正如我所说的,我希望一切对用户来说都是无缝的。除了此外部接口之外,由于不同的原因,隐藏的代码被分解为单独的Windows服务。这一切都是在Windows Embedded上运行的,我们的愿景是,该设备更像是一个设备,客户端甚至无法洞察内部运行的操作系统

当我尝试运行这两个服务时,我会得到一个AddressReadyUseException。我从2009年的这篇文章中假设

我不能使用相同的根地址。有没有一种简单的方法可以在不同的Windows服务(AppDomains)之间共享根目录

我在xml配置中没有使用baseAddress,也没有为每个路径创建单独的WCF服务,但这是一个很大的工作