C# 尝试将WCF应用程序上载到服务器时出错

C# 尝试将WCF应用程序上载到服务器时出错,c#,asp.net,wcf,asp.net-4.0,C#,Asp.net,Wcf,Asp.net 4.0,我正在尝试在web服务器上托管我的WCF应用程序。我得到了这个错误,但它在我的本地系统中运行良好 错误 此集合已包含具有方案http的地址。那里 此集合中每个方案最多只能有一个地址。如果你的 服务正在IIS中托管。您可以通过设置 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' 使真实或具体化 “system.serviceModel/serviceHostingEnvironment/base

我正在尝试在web服务器上托管我的WCF应用程序。我得到了这个错误,但它在我的本地系统中运行良好

错误

此集合已包含具有方案http的地址。那里 此集合中每个方案最多只能有一个地址。如果你的 服务正在IIS中托管。您可以通过设置 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' 使真实或具体化 “system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters”

参数名称:item

说明:执行当前web请求期间发生未经处理的异常。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源

异常详细信息:System.ArgumentException:此集合已包含具有方案http的地址。最多可以有 此集合中每个方案一个地址。如果你的服务是 托管在IIS中您可以通过设置 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' 使真实或具体化 “system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters”。 参数名称:item

源错误:

在执行过程中生成了未处理的异常 当前web请求。关于货物来源和位置的信息 可以使用下面的异常堆栈跟踪来识别异常

堆栈跟踪:

[ArgumentException:此集合已包含具有的地址 方案http。在该方案中,每个方案最多只能有一个地址 集合。如果您的服务托管在IIS中,则可以修复 设置问题 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' 使真实或具体化 “system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters”。 参数名称:项]
System.ServiceModel.UrischemeKeydCollection.InsertItem(Int32索引, Uri项)+12089046
System.Collections.Generic.SynchronizedCollection`1.添加(T项)+78
System.ServiceModel.UrischemeKeydCollection..ctor(Uri[]地址) +72 System.ServiceModel.ServiceHost..ctor(类型serviceType,Uri[]基本地址)+141
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(类型 服务类型,Uri[]基本地址)+30
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(字符串 构造函数字符串,Uri[]基地址)+420
System.ServiceModel.HostingManager.CreateService(字符串 标准化虚拟路径)+1440
System.ServiceModel.HostingManager.ActivateService(字符串 标准化虚拟路径)+44
System.ServiceModel.HostingManager.EnsureServiceAvailable(字符串 标准化虚拟路径)+615

[ServiceActivationException:无法启动服务'/GUIService.svc' 由于编译期间出现异常而激活。异常 消息是:此集合已包含具有scheme的地址 http。此集合中每个方案最多只能有一个地址。 如果您的服务托管在IIS中,您可以通过 背景 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' 使真实或具体化 “system.serviceModel/serviceHostingEnvironment/baseAddressPrefixFilters”。 参数名称:item.]System.Runtime.AsyncResult.End(IAsyncResult) 结果)+679246
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult 结果)+190
System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar)+300622
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)+8837348


任何人都可以帮我解决这个问题。

通过以下链接,您的问题就会得到解决。这些链接也解决了同样的问题


我建议检查您的web配置文件层次结构,以确认您没有使用“无地址”的多个端点。

通过以下链接,您将解决问题。这些链接也解决了同样的问题

我建议检查您的web配置文件层次结构,以确认您没有使用“无地址”的多个端点

请在发布问题之前搜索

您可以检查以下解决方案

  • 代码解决方案:
  • 配置解决方案:
我建议您使用配置解决方案,该解决方案易于动态更改

检查以下内容,了解如何更改应用程序web配置:

<system.serviceModel>
    <serviceHostingEnvironment>
        <baseAddressPrefixFilters>
            <add prefix="net.tcp://payroll.myorg.com:8000"/>
            <add prefix="http://shipping.myorg.com:9000"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
</system.serviceModel>

是吗
仅基地址,用于它们的
各自的计划,将
允许通过。这个
baseAddressPrefixFilter不支持
支持任何通配符

IIS提供的基地址可能是 将地址绑定到其他方案 baseAddressPrefixFilter中不存在 列表这些地址将不会被删除 过滤掉

Dns解决方案(未经测试): 我认为,如果您针对您的web应用程序创建了一个新的dns条目,添加了一个新的网站,并为其提供了一个与dns条目匹配的主机头,您将完全缓解此问题,并且不必编写自定义代码或向web.config文件添加前缀。

来自SO的原始帖子:

请在发布问题之前搜索

您可以检查以下解决方案

  • 代码解决方案:
  • 配置解决方案:
我建议您使用配置解决方案,该解决方案易于动态更改

检查以下内容,了解如何更改应用程序web配置:

<system.serviceModel>
    <serviceHostingEnvironment>
        <baseAddressPrefixFilters>
            <add prefix="net.tcp://payroll.myorg.com:8000"/>
            <add prefix="http://shipping.myorg.com:9000"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
</system.serviceModel>

是吗
仅基地址,用于它们的
各自的计划,将
全部的