C# 无法在服务器上激活二进制http绑定

C# 无法在服务器上激活二进制http绑定,c#,.net,wcf,wcf-binding,C#,.net,Wcf,Wcf Binding,我正尝试在WCF服务中使用二进制消息编码,下面是这个站点上的许多示例 在服务器上,我将绑定声明为: <customBinding> <binding name="binaryHttpBinding"> <binaryMessageEncoding maxReadPoolSize="4096000" maxSessionSize="4096000" maxWritePoolSize="4096000"> <r

我正尝试在WCF服务中使用二进制消息编码,下面是这个站点上的许多示例

在服务器上,我将绑定声明为:

<customBinding>
    <binding name="binaryHttpBinding">
        <binaryMessageEncoding maxReadPoolSize="4096000" maxSessionSize="4096000" maxWritePoolSize="4096000">
            <readerQuotas maxDepth="32" maxStringContentLength="4096000"
            maxArrayLength="4096000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binaryMessageEncoding>
        <httpTransport maxBufferPoolSize="4096000" maxBufferSize="4096000" maxReceivedMessageSize="4096000"/>
    </binding>
</customBinding>

服务已设置为使用它(我认为):


客户具有相同的声明:

<customBinding>
    <binding name="binaryHttpBinding">
        <binaryMessageEncoding maxReadPoolSize="4096000" maxSessionSize="4096000" maxWritePoolSize="4096000">
            <readerQuotas maxDepth="32" maxStringContentLength="4096000"
            maxArrayLength="4096000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binaryMessageEncoding>
        <httpTransport maxBufferPoolSize="4096000" maxBufferSize="4096000" maxReceivedMessageSize="4096000"/>
    </binding>
</customBinding>

以及:


客户端似乎正在工作,但服务器引发异常,表明绑定未到位:

内容类型应用程序/soap+msbin1 已发送到预期的服务 text/xml;字符集=utf-8。客户 和服务绑定可能是 不匹配

日志文件中此错误的前一个错误是在尝试打开服务主机时抛出的,这一定是原因

配置评估上下文不可用 找到了


我为这条消息尝试的搜索链接都没有帮助。那么,我缺少什么基本内容呢?

您是否尝试过在服务器上设置主机来补充端点

我想应该是这样的:

<service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.ContentUploadService">    
<host>
   <baseAddresses>
      <add baseAddress="http://foo.com/ContentUploadService.svc"/>
   </baseAddresses>
</host>
<endpoint address="" binding="customBinding" indingConfiguration="binaryHttpBinding" contract="MyService.IContentUpload" name="MyService.ContentUploadService" />


希望这有帮助

在我看来,您的服务使用的是默认配置,如果找不到明确的配置,就会出现这种情况。确保元素的name属性与服务类(包括命名空间)的完全限定名完全匹配。

web.config中是否有服务配置?服务器应用程序中是否引用System.ServiceModel.dll?是和是。如果我将绑定更改为basicHttpBinding(只要消息大小保持<64K),则服务可以正常工作。
如果使用未注册为扩展的未知绑定或行为配置,则通常会触发
未找到配置评估上下文。确保配置中没有类型。还要确保您的服务/@名称正确-它必须是.svc文件中定义的Namespace.ServiceName。二进制消息编码的任何部分是否在其他地方声明(在System.ServiceModel之外?)。由于服务使用不同的绑定,要么我声明不正确,要么我没有必要的引用。所有二进制编码都在System.ServiceModel中声明。您遇到的问题是由于服务无法识别服务的配置(如果没有在服务上声明端点,您将得到一个默认端点,它恰好使用BasicHttpBinding)。您是否在IIS中托管该服务?是否在IIS应用程序根目录下定义了web.config?
<endpoint
    address="http://foo.com/ContentUploadService.svc"
    binding="customBinding"
    bindingConfiguration="binaryHttpBinding"
    contract="MyService.IContentUpload"
    name="MyService.ContentUploadService"/>
<service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.ContentUploadService">    
<host>
   <baseAddresses>
      <add baseAddress="http://foo.com/ContentUploadService.svc"/>
   </baseAddresses>
</host>
<endpoint address="" binding="customBinding" indingConfiguration="binaryHttpBinding" contract="MyService.IContentUpload" name="MyService.ContentUploadService" />