Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MSMQ绑定不匹配_C#_Wcf_Msmq_Netmsmqbinding - Fatal编程技术网

C# MSMQ绑定不匹配

C# MSMQ绑定不匹配,c#,wcf,msmq,netmsmqbinding,C#,Wcf,Msmq,Netmsmqbinding,我们有一个过去正常工作的设置,在过去几个月的某个时候已经停止。我们使用在配置中指定的自定义死信队列,但基本上是这样设置的:: MsmqIntegrationBinding msmq = new MsmqIntegrationBinding( // Defaults to WindowsDomain. We want all messages to be authenticated. MsmqIntegrationSecurityMode.Transport); msmq.De

我们有一个过去正常工作的设置,在过去几个月的某个时候已经停止。我们使用在配置中指定的自定义死信队列,但基本上是这样设置的::

MsmqIntegrationBinding msmq = new MsmqIntegrationBinding(
    // Defaults to WindowsDomain.  We want all messages to be authenticated.
    MsmqIntegrationSecurityMode.Transport);

msmq.DeadLetterQueue = DeadLetterQueue.Custom;
msmq.CustomDeadLetterQueue = new Uri("net.msmq://localhost/private/BulkUpdatesDeadLetter");
我们已经开始得到这个错误,这似乎很清楚:

System.InvalidOperationException:绑定和MSMQ配置之间发生不匹配。无法发送消息。绑定中指定的自定义死信队列必须是事务队列。确保自定义死信队列地址正确,并且该队列是事务性队列

我们已经验证了我们在配置中指向了正确的队列,并且该队列是事务性的。是否有任何其他问题可能导致抛出此异常,或者我们只是缺少一些显而易见的东西


更新:让我们的web操作团队删除并重新创建队列,但仍然收到错误。

本文提供了以下代码

namespace System.ServiceModel.Configuration
{
使用系统配置;
使用System.ServiceModel.Channel;
使用System.ServiceModel;
使用System.Collections.Generic;
利用制度全球化;
运用系统反思;
使用System.Xml;
使用系统安全;
公共密封部分类绑定节:配置节,IConfigurationContextProviderInternal
{ 
静态配置=null;
配置属性集合属性;
公共绑定操作(){}
字典绑定集合元素
{
得到
{ 
Dictionary bindingCollectionElements=新字典();
foreach(此.Properties中的ConfigurationProperty属性)
{
bindingCollectionElements.Add(property.Name,this[property.Name]);
} 
返回绑定集合元素;
} 
}
新建公共BindingCollectionElement此[字符串绑定]
{
得到
{ 
返回(BindingCollectionElement)基[binding];
} 
} 
受保护的覆盖配置属性集合属性
{
得到
{
if(this.properties==null)
{
this.properties=new ConfigurationPropertyCollection();
} 
此.UpdateBindingSections();
返回此文件。属性;
}
}
[ConfigurationProperty(ConfigurationStrings.BasicHttpBindingCollectionElementName,Options=ConfigurationPropertyOptions.None)]
公共BasicHttpBindingCollectionElement BasicHttpBinding
{ 
获取{return(BasicHttpBindingCollectionElement)基[ConfigurationString.BasicHttpBindingCollectionElementName];}
} 
//只能从BindingSectionGroup TryAdd调用/设置此属性
静态配置
{ 
获取{return BindingsSection.configuration;}
设置{BindingsSection.configuration=value;}
} 
[ConfigurationProperty(ConfigurationStrings.CustomBindingCollectionElementName,Options=ConfigurationPropertyOptions.None)]
公共CustomBindingCollectionElement自定义绑定
{
获取{return(CustomBindingCollectionElement)基[ConfigurationStrings.CustomBindingCollectionElementName];}
} 
[ConfigurationProperty(ConfigurationStrings.MsmqIntegrationBindingCollectionElementName,Options=ConfigurationPropertyOptions.None)]
公共MsmqIntegrationBindingCollectionElement MsmqIntegrationBinding
{
获取{return(MsmqIntegrationBindingCollectionElement)基[ConfigurationStrings.MsmqIntegrationBindingCollectionElementName];}
}
[ConfigurationProperty(ConfigurationStrings.NetPeerTcpBindingCollectionElementName,Options=ConfigurationPropertyOptions.None)]
公共NetPeerTcpBinding集合元素NetPeerTcpBinding
{
获取{return(NetPeerTcpBindingCollectionElement)基[ConfigurationStrings.NetPeerTcpBindingCollectionElementName];}
} 
[ConfigurationProperty(ConfigurationStrings.NetMsmqBindingCollectionElementName,Options=ConfigurationPropertyOptions.None)]
公共NetMsmqBindingCollectionElement NetMsmqBinding
{
获取{return(NetMsmqBindingCollectionElement)基[ConfigurationStrings.NetMsmqBindingCollectionElementName];}
} 
[ConfigurationProperty(ConfigurationStrings.NetNamedPipeBindingCollectionElementName,Options=ConfigurationPropertyOptions.None)]
公共NetNamedPipeBindingCollectionElement NetNamedPipeBinding
{
获取{return(NetNamedPipeBindingCollectionElement)基[ConfigurationString.NetNamedPipeBindingCollectionElementName];}
}
[ConfigurationProperty(ConfigurationStrings.NetTcpBindingCollectionElementName,Options=ConfigurationPropertyOptions.None)]
公共NetTcpBindingCollectionElement NetTcpBinding
{
获取{return(NetTcpBindingCollectionElement)基[ConfigurationStrings.NetTcpBindingCollectionElementName];}
} 
[ConfigurationProperty(ConfigurationStrings.WSFederationHttpBindingCollectionElementName,Options=ConfigurationPropertyOptions.None)]
公共WSFederationHttpBindingCollectionElement WSFederationHttpBinding
{
获取{return(WSFederationHttpB
  namespace System.ServiceModel.Configuration 
    {
        using System.Configuration; 
        using System.ServiceModel.Channels; 
        using System.ServiceModel;
        using System.Collections.Generic; 
        using System.Globalization;
        using System.Reflection;
        using System.Xml;
        using System.Security; 

        public sealed partial class BindingsSection : ConfigurationSection, IConfigurationContextProviderInternal 
        { 
            static Configuration configuration = null;
            ConfigurationPropertyCollection properties; 

            public BindingsSection() { }

            Dictionary<string, bindingcollectionelement=""> BindingCollectionElements 
            {
                get
                { 
                    Dictionary<string, bindingcollectionelement=""> bindingCollectionElements = new Dictionary<string, bindingcollectionelement="">();

                    foreach (ConfigurationProperty property in this.Properties)
                    {
                        bindingCollectionElements.Add(property.Name, this[property.Name]);
                    } 

                    return bindingCollectionElements; 
                } 
            }

            new public BindingCollectionElement this[string binding]
            {
                get
                { 
                    return (BindingCollectionElement)base[binding];
                } 
            } 

            protected override ConfigurationPropertyCollection Properties 
            {
                get
                {
                    if (this.properties == null) 
                    {
                        this.properties = new ConfigurationPropertyCollection(); 
                    } 

                    this.UpdateBindingSections(); 
                    return this.properties;
                }
            }

            [ConfigurationProperty(ConfigurationStrings.BasicHttpBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)]
            public BasicHttpBindingCollectionElement BasicHttpBinding 
            { 
                get { return (BasicHttpBindingCollectionElement)base[ConfigurationStrings.BasicHttpBindingCollectionElementName]; }
            } 

            // This property should only be called/set from BindingsSectionGroup TryAdd
            static Configuration Configuration
            { 
                get { return BindingsSection.configuration; }
                set { BindingsSection.configuration = value; } 
            } 

            [ConfigurationProperty(ConfigurationStrings.CustomBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)] 
            public CustomBindingCollectionElement CustomBinding
            {
                get { return (CustomBindingCollectionElement)base[ConfigurationStrings.CustomBindingCollectionElementName]; }
            } 

            [ConfigurationProperty(ConfigurationStrings.MsmqIntegrationBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)] 
            public MsmqIntegrationBindingCollectionElement MsmqIntegrationBinding 
            {
                get { return (MsmqIntegrationBindingCollectionElement)base[ConfigurationStrings.MsmqIntegrationBindingCollectionElementName]; } 
            }

            [ConfigurationProperty(ConfigurationStrings.NetPeerTcpBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)]
            public NetPeerTcpBindingCollectionElement NetPeerTcpBinding 
            {
                get { return (NetPeerTcpBindingCollectionElement)base[ConfigurationStrings.NetPeerTcpBindingCollectionElementName]; } 
            } 

            [ConfigurationProperty(ConfigurationStrings.NetMsmqBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)] 
            public NetMsmqBindingCollectionElement NetMsmqBinding
            {
                get { return (NetMsmqBindingCollectionElement)base[ConfigurationStrings.NetMsmqBindingCollectionElementName]; }
            } 

            [ConfigurationProperty(ConfigurationStrings.NetNamedPipeBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)] 
            public NetNamedPipeBindingCollectionElement NetNamedPipeBinding 
            {
                get { return (NetNamedPipeBindingCollectionElement)base[ConfigurationStrings.NetNamedPipeBindingCollectionElementName]; } 
            }

            [ConfigurationProperty(ConfigurationStrings.NetTcpBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)]
            public NetTcpBindingCollectionElement NetTcpBinding 
            {
                get { return (NetTcpBindingCollectionElement)base[ConfigurationStrings.NetTcpBindingCollectionElementName]; } 
            } 

            [ConfigurationProperty(ConfigurationStrings.WSFederationHttpBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)] 
            public WSFederationHttpBindingCollectionElement WSFederationHttpBinding
            {
                get { return (WSFederationHttpBindingCollectionElement)base[ConfigurationStrings.WSFederationHttpBindingCollectionElementName]; }
            } 

            [ConfigurationProperty(ConfigurationStrings.WS2007FederationHttpBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)] 
            public WS2007FederationHttpBindingCollectionElement WS2007FederationHttpBinding 
            {
                get { return (WS2007FederationHttpBindingCollectionElement)base[ConfigurationStrings.WS2007FederationHttpBindingCollectionElementName]; } 
            }

            [ConfigurationProperty(ConfigurationStrings.WSHttpBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)]
            public WSHttpBindingCollectionElement WSHttpBinding 
            {
                get { return (WSHttpBindingCollectionElement)base[ConfigurationStrings.WSHttpBindingCollectionElementName]; } 
            } 

            [ConfigurationProperty(ConfigurationStrings.WS2007HttpBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)] 
            public WS2007HttpBindingCollectionElement WS2007HttpBinding
            {
                get { return (WS2007HttpBindingCollectionElement)base[ConfigurationStrings.WS2007HttpBindingCollectionElementName]; }
            } 

            [ConfigurationProperty(ConfigurationStrings.WSDualHttpBindingCollectionElementName, Options = ConfigurationPropertyOptions.None)] 
            public WSDualHttpBindingCollectionElement WSDualHttpBinding 
            {
                get { return (WSDualHttpBindingCollectionElement)base[ConfigurationStrings.WSDualHttpBindingCollectionElementName]; } 
            }

            public static BindingsSection GetSection(Configuration config)
            { 
                if (config == null)
                { 
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("config"); 
                }

                return (BindingsSection)config.GetSection(ConfigurationStrings.BindingsSectionGroupPath);
            }

            public List<bindingcollectionelement> BindingCollections 
            {
                get
                { 
                    List<bindingcollectionelement> bindingCollections = new List<bindingcollectionelement>();
                    foreach (ConfigurationProperty property in this.Properties) 
                    {
                        bindingCollections.Add(this[property.Name]);
                    }

                    return bindingCollections;
                } 
            } 

            internal static bool TryAdd(string name, Binding binding, Configuration config, out string bindingSectionName) 
            {
                bool retval = false;
                BindingsSection.Configuration = config;
                try
                {
                    retval = BindingsSection.TryAdd(name, binding, out bindingSectionName); 
                } 
                finally
                { 
                    BindingsSection.Configuration = null;
                }
                return retval;
            } 

            internal static bool TryAdd(string name, Binding binding, out string bindingSectionName) 
            { 
                // TryAdd built on assumption that BindingsSectionGroup.Configuration is valid.
                // This should be protected at the callers site.  If assumption is invalid, then 
                // configuration system is in an indeterminate state.  Need to stop in a manner that
                // user code can not capture.
                if (null == BindingsSection.Configuration)
                { 
                    DiagnosticUtility.DebugAssert("The TryAdd(string name, Binding binding, Configuration config, out string binding) variant of this function should always be called first. The Configuration object is not set.");
                    DiagnosticUtility.FailFast("The TryAdd(string name, Binding binding, Configuration config, out string binding) variant of this function should always be called first. The Configuration object is not set."); 
                } 

                bool retval = false; 
                string outBindingSectionName = null;
                BindingsSection sectionGroup = BindingsSection.GetSection(BindingsSection.Configuration);
                sectionGroup.UpdateBindingSections();
                foreach (string sectionName in sectionGroup.BindingCollectionElements.Keys) 
                {
                    BindingCollectionElement bindingCollectionElement = sectionGroup.BindingCollectionElements[sectionName]; 

                    // Save the custom bindings as the last choice
                    if (!(bindingCollectionElement is CustomBindingCollectionElement)) 
                    {
                        MethodInfo tryAddMethod = bindingCollectionElement.GetType().GetMethod("TryAdd", BindingFlags.Instance | BindingFlags.NonPublic);
                        if (tryAddMethod != null)
                        { 
                            retval = (bool)tryAddMethod.Invoke(bindingCollectionElement, new object[] { name, binding, BindingsSection.Configuration });
                            if (retval) 
                            { 
                                outBindingSectionName = sectionName;
                                break; 
                            }
                        }
                    }
                } 
                if (!retval)
                { 
                    // Much of the time, the custombinding should come out ok. 
                    CustomBindingCollectionElement customBindingSection = CustomBindingCollectionElement.GetBindingCollectionElement();
                    retval = customBindingSection.TryAdd(name, binding, BindingsSection.Configuration); 
                    if (retval)
                    {
                        outBindingSectionName = ConfigurationStrings.CustomBindingCollectionElementName;
                    } 
                }

                // This little oddity exists to make sure that the out param is assigned to before the method 
                // exits.
                bindingSectionName = outBindingSectionName; 
                return retval;
            }

            /// <securitynote> 
            /// Critical - uses SecurityCritical method UnsafeLookupCollection which elevates
            /// Safe - does not leak config objects 
            /// </securitynote> 
            [SecurityCritical, SecurityTreatAsSafe]
            void UpdateBindingSections() 
            {
                ExtensionElementCollection bindingExtensions = ExtensionsSection.UnsafeLookupCollection(ConfigurationStrings.BindingExtensions, ConfigurationHelpers.GetEvaluationContext(this));

                // Extension collections are additive only (BasicMap) and do not allow for <clear> 
                // or <remove> tags, nor do they allow for overriding an entry.  This allows us
                // to optimize this to only walk the binding extension collection if the counts 
                // mismatch. 
                if (bindingExtensions.Count != this.properties.Count)
                { 
                    foreach (ExtensionElement bindingExtension in bindingExtensions)
                    {
                        if (null != bindingExtension)
                        { 
                            if (!this.properties.Contains(bindingExtension.Name))
                            { 
                                ConfigurationProperty property = new ConfigurationProperty(bindingExtension.Name, 
                                    Type.GetType(bindingExtension.Type, true),
                                    null, 
                                    ConfigurationPropertyOptions.None);

                                this.properties.Add(property);
                            } 
                        }
                    } 
                } 
            }

            /// <securitynote>
            /// Critical - uses SecurityCritical method UnsafeGetAssociatedBindingCollectionElement which elevates
            /// Safe - does not leak config objects
            /// </securitynote> 
            [SecurityCritical, SecurityTreatAsSafe]
            internal static void ValidateBindingReference(string binding, string bindingConfiguration, ContextInformation evaluationContext, ConfigurationElement configurationElement) 
            { 
                // ValidateBindingReference built on assumption that evaluationContext is valid.
                // This should be protected at the callers site.  If assumption is invalid, then 
                // configuration system is in an indeterminate state.  Need to stop in a manner that
                // user code can not capture.
                if (null == evaluationContext)
                { 
                    DiagnosticUtility.DebugAssert("ValidateBindingReference() should only called with valid ContextInformation");
                    DiagnosticUtility.FailFast("ValidateBindingReference() should only called with valid ContextInformation"); 
                } 

                if (!String.IsNullOrEmpty(binding)) 
                {
                    BindingCollectionElement bindingCollectionElement = null;

                    if (null != evaluationContext) 
                    {
                        bindingCollectionElement = ConfigurationHelpers.UnsafeGetAssociatedBindingCollectionElement(evaluationContext, binding); 
                    } 
                    else
                    { 
                        bindingCollectionElement = ConfigurationHelpers.UnsafeGetBindingCollectionElement(binding);
                    }

                    if (bindingCollectionElement == null) 
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidSection, 
                            ConfigurationHelpers.GetBindingsSectionPath(binding)), 
                            configurationElement.ElementInformation.Source,
                            configurationElement.ElementInformation.LineNumber)); 
                    }

                    if (!String.IsNullOrEmpty(bindingConfiguration))
                    { 
                        if (!bindingCollectionElement.ContainsKey(bindingConfiguration))
                        { 
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigInvalidBindingName, 
                                bindingConfiguration,
                                ConfigurationHelpers.GetBindingsSectionPath(binding), 
                                ConfigurationStrings.BindingConfiguration),
                                configurationElement.ElementInformation.Source,
                                configurationElement.ElementInformation.LineNumber));
                        } 
                    }
                } 
            } 

            ContextInformation IConfigurationContextProviderInternal.GetEvaluationContext() 
            {
                return this.EvaluationContext;
            }

            /// <securitynote>
            ///   RequiresReview - the return value will be used for a security decision -- see comment in interface definition 
            /// </securitynote> 
            ContextInformation IConfigurationContextProviderInternal.GetOriginalEvaluationContext()
            { 
                DiagnosticUtility.DebugAssert("Not implemented: IConfigurationContextProviderInternal.GetOriginalEvaluationContext");
                return null;
            }
        } 
    }

    </remove></clear></bindingcollectionelement></bindingcollectionelement></bindingcollectionelement></string,></string,></string,>