代码之家  ›  专栏  ›  技术社区  ›  ETFairfax

无法加载DLL“mqrt.DLL”

  •  13
  • ETFairfax  · 技术社区  · 11 年前

    我开发了一个WCF服务,它作为Windows服务托管,并公开了MSMQ端点。

    我在SERVER1上有客户端应用程序,在SERVER2上有MSMQ和WCF服务。

    当SERVER1/ClientApp试图将消息推送到SERVER2 MSMQ时,我会收到以下错误:

        System.TypeInitializationException: The type initializer for 'System.ServiceModel.Channels.Msmq' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'mqrt.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
           at System.ServiceModel.Channels.UnsafeNativeMethods.MQGetPrivateComputerInformation(String computerName, IntPtr properties)
           at System.ServiceModel.Channels.MsmqQueue.GetMsmqInformation(Version& version, Boolean& activeDirectoryEnabled)
           at System.ServiceModel.Channels.Msmq..cctor()
           --- End of inner exception stack trace ---
           at System.ServiceModel.Channels.Msmq.EnterXPSendLock(Boolean& lockHeld, ProtectionLevel protectionLevel)
           at System.ServiceModel.Channels.MsmqOutputChannel.OnSend(Message message, TimeSpan timeout)
           at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
           at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    
    Exception rethrown at [7]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at FacilityManager.Service.NotificationsProcessorServiceReference.INotificationsProcessor.SendNewReactiveTaskNotifications(NewReactiveTaskDataContract newReactiveTaskDataContract)
    

    SERVER1和SERVER2都运行Windows Server 2008 R2 Enterprise(6.1 SP1),并且都通过服务器管理器中的添加功能安装了MSMQ。

    我知道DLL丢失了(从错误中可以明显看出!),但我不知道应该安装什么才能将DLL放在应该的位置。

    在Windows资源管理器中搜索显示,DLL存在于两台服务器上的以下目录中。。。。

    • C: \Windows\System32
    • C: \Windows\SysWOW64
    • C: \Windows\winsxs\x86_microsoft-Windows-msmq-runtime-core_31bf3856a364e35_6.1.7601.17514_none_5768e2ad17453bd6
    • C: \Windows\winsxs\amd64_microsoft-Windows-msmq-runtime-core_31bf3856a364e35_6.1.760.17514_none_b3877e30cfa2ad0c

    感谢您的帮助。

    3 回复  |  直到 11 年前
        1
  •  25
  •   SChalice    10 年前

    显而易见的旁白;如果你没有 Windows功能->Microsoft消息队列(MSMQ)服务器 安装后,您将收到此错误。只需转到 程序和功能 然后 打开或关闭Windows功能 .

        2
  •  5
  •   Community c0D3l0g1c    7 年前

    我一点也不知道,但现在情况正在好转。

    在SO和谷歌上呆了几个小时后,我写了一个快速控制台应用程序,用从这里获取的代码检查MSMQ是否安装在这两台服务器上。。。

    https://stackoverflow.com/a/16104212/192999

    我在Server1和Server2上都运行了控制台应用程序,结果都是True to IsMsmqInstalled。

    然后我运行了我的应用程序,“无法加载DLL‘mqrt.DLL’”错误不再出现。

    我不知道打给 NativeMethods.LoadLibrary("Mqrt.dll"); 注册了DLL或其他什么,但它确实解决了我的问题。

    我希望这对将来的人有所帮助!

        3
  •  1
  •   Community c0D3l0g1c    7 年前

    这可能是由于SERVER2上的服务在MSMQ完成初始化之前启动并完成初始化而导致的。测试这一点的最简单方法是重新启动承载WCF MSMQ端点的服务。如果WCF服务是在IIS中托管的,那么跳过应用程序池可能也会做同样的事情,但我不确定——我从未处理过IIS托管的MSMQ端点。

    如果重新启动服务可以解决您的问题,并且您自己的服务是Windows服务,那么您可以将MSMQ添加为您自己服务的依赖项,以便它将延迟启动,直到MSMQ准备就绪。 This 关于服务器故障的回答描述了如何做到这一点。顺便说一句,你想依赖的服务被称为“消息排队”