c# - 使用 netMsmqBinding 与 IIS 托管绑定(bind)时,WCF 服务托管失败

标签 c# wcf iis exception netmsmqbinding

使用 IIS 托管时,WCF 服务失败。该服务的 web.config 是

<system.serviceModel>
    <bindings>
        <netMsmqBinding>
            <binding name="msmqbindingnontransactionalnonsecure" exactlyOnce="False">
                <security mode="None" />
            </binding>
        </netMsmqBinding>
    </bindings>
    <services>
        <service name="MsmqService.MsmqService">
            <endpoint address="net.msmq://localhost/private/msmqpoc/MsmqService.svc"  binding="netMsmqBinding" bindingConfiguration="msmqbindingnontransactionalnonsecure" contract="MsmqWCFService.IMsmqContract" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                <serviceMetadata httpGetEnabled="true"/>
                <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

服务契约(Contract)是

[ServiceContract]
public interface IMsmqContract
{
    [OperationContract(IsOneWay = true)]
    void SendMessage(string message);
}

在 IIS 中托管服务时,显示以下消息:

Server Error in '/msmqpoc' Application.
--------------------------------------------------------------------------------

Binding validation failed because the binding's ExactlyOnce property is set to true while the destination queue is non-transactional. The service host cannot be opened. Resolve this conflict by setting the ExactlyOnce property to false or creating a transactional queue for this binding. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Binding validation failed because the binding's ExactlyOnce property is set to true while the destination queue is non-transactional. The service host cannot be opened. Resolve this conflict by setting the ExactlyOnce property to false or creating a transactional queue for this binding.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.      
Stack Trace:
[InvalidOperationException: Binding validation failed because the binding's ExactlyOnce property is set to true while the destination queue is non-transactional. The service host cannot be opened. Resolve this conflict by setting the ExactlyOnce property to false or creating a transactional queue for this binding.]

配置已经设置为exactOnce=false,不确定为什么会出现此错误,有帮助吗?

最佳答案

我只能猜测您的服务没有获取正确的配置文件。我建议仔细检查一下。我看不出您发布的配置文件有任何问题。

有点偏离主题,我冒昧地说您应该考虑为什么要使用非事务性队列。您使用它们的唯一原因是您的整体架构是否可以容忍消息丢失。

例如,在某些低延迟系统中,消息在失效之前最多仅在几秒钟内有值(value)。因此,在这种情况下,您不需要使用事务队列。

如果您不能容忍消息丢失,则必须使用事务队列。

关于c# - 使用 netMsmqBinding 与 IIS 托管绑定(bind)时,WCF 服务托管失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9752373/

相关文章:

WCF:maxStringContentLength 始终设置为 8192

powershell - 为 Azure 资源管理器模板部署 DSC 扩展时出现问题

asp.net - 将 url 缩短为 cms

c# - 转换具有几种不同比率的多组数字的最佳方法

c# - 如何在 C# 中查找最新版本的文件名

c# - 仅基于 WPF、WCF 和 ADO.net 的 .Net 项目同时将 DB 作为 Sybase 是否可能?

c# - Entity Framework 是否支持父级引用 0..1 个子级,子级引用 1 个父级?

apache - 更改 Apache 设置,因此对于 `https`,它应该监听 8443 而不是 443

c# - 偶数斐波那契数之和

c# - SQL查询在.net项目中不起作用,但在adminer/phpmyadmin中正常运行