Unable to load DLL 'mqrt.dll'
Asked Answered
T

3

13

I've developed a WCF Service which is hosted as a Windows Service and exposes a MSMQ endpoint.

I have the client app on SERVER1, and the MSMQ and WCF Service on SERVER2.

When the SERVER1/ClientApp attempts to push a message on to the SERVER2 MSMQ, I get the following errror:

    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)

Both SERVER1 and SERVER2 are running Windows Server 2008 R2 Enterprise (6.1 SP1), and both have had MSMQ installed via the Add Features in Server Manager.

I understand that the DLL is missing (fairly obvious from the error!), but I've no idea what I should be installing to get the dll where it should be.

A search in Windows Explorer shows that the DLL is present in the following directories on both servers....

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

Any help appreciated.

Tophole answered 2/9, 2013 at 16:5 Comment(2)
Turn on fusion logging, also you can try using Dependency Walker on your binaries.Mulvey
Also I would recommend re-installing msmq on the client machine.Output
T
5

I'm none the wiser but things are working now.

After hours on SO and Google, I ended up just checking that MSMQ was installed on both Servers by writing a quick console application with the code grabbed from here...

https://mcmap.net/q/903936/-prevent-application-start-fail-if-msmq-not-installed

I ran the console app on both Server1 and Server2 and both came back with a result of True to IsMsmqInstalled.

I then ran my application and the "Unable to load DLL 'mqrt.dll'" error was no longer being raised.

I don't know if the call to NativeMethods.LoadLibrary("Mqrt.dll"); registered the DLL or something, but it certainly fixed my problem.

I hope this helps someone in the future!

Tophole answered 3/9, 2013 at 13:56 Comment(4)
@JohnBreakwell - Apologies for the late reply. Yes, both servers have been rebooted since and the WCF services have restarted and work as expected.Tophole
This makes no sense to me. Simply checking if MSMQ is installed magically fixed your issue? I am running into the same issue and I can see that the MSMQ feature is installed and the service is running. I also verified that the DLL is present on the server and is the right version/size/etc. Is it possible you did something else that may have fixed the issue? Such as reboot the server or run a Windows update?Ginny
@TravisParks - It made no sense to me either. I can't remember everything about the issue now, but I do remember it all of a sudden working after doing as I've said in the answer. We've moved away from MSMQ/WCF and we're now doing our pub/sub with RabbitMQ and Windows Services which, for our needs, seems so much easier to configure, install and troubleshoot.Tophole
For me, simply restarting the server fixed the issue. I have two identical machines, a primary and a fail-over. This error occurred randomly (every 2 or 3 times) on the fail-over server, but worked perfectly on the primary machine. I had installed the MSMQ Windows Feature as part of the software and had not yet rebooted the machine. Apparently, it needed it, because now the errors no longer occur.Ginny
Y
25

An obvious aside; If you don't have the Windows Feature -> Microsoft Message Queue (MSMQ) Server installed then you will get this error. Simply go to Programs and Features and then Turn Windows Feature on or off.

Yard answered 2/11, 2014 at 22:28 Comment(1)
Anyone randomly googling this error, this is more than likely the issue.Permute
T
5

I'm none the wiser but things are working now.

After hours on SO and Google, I ended up just checking that MSMQ was installed on both Servers by writing a quick console application with the code grabbed from here...

https://mcmap.net/q/903936/-prevent-application-start-fail-if-msmq-not-installed

I ran the console app on both Server1 and Server2 and both came back with a result of True to IsMsmqInstalled.

I then ran my application and the "Unable to load DLL 'mqrt.dll'" error was no longer being raised.

I don't know if the call to NativeMethods.LoadLibrary("Mqrt.dll"); registered the DLL or something, but it certainly fixed my problem.

I hope this helps someone in the future!

Tophole answered 3/9, 2013 at 13:56 Comment(4)
@JohnBreakwell - Apologies for the late reply. Yes, both servers have been rebooted since and the WCF services have restarted and work as expected.Tophole
This makes no sense to me. Simply checking if MSMQ is installed magically fixed your issue? I am running into the same issue and I can see that the MSMQ feature is installed and the service is running. I also verified that the DLL is present on the server and is the right version/size/etc. Is it possible you did something else that may have fixed the issue? Such as reboot the server or run a Windows update?Ginny
@TravisParks - It made no sense to me either. I can't remember everything about the issue now, but I do remember it all of a sudden working after doing as I've said in the answer. We've moved away from MSMQ/WCF and we're now doing our pub/sub with RabbitMQ and Windows Services which, for our needs, seems so much easier to configure, install and troubleshoot.Tophole
For me, simply restarting the server fixed the issue. I have two identical machines, a primary and a fail-over. This error occurred randomly (every 2 or 3 times) on the fail-over server, but worked perfectly on the primary machine. I had installed the MSMQ Windows Feature as part of the software and had not yet rebooted the machine. Apparently, it needed it, because now the errors no longer occur.Ginny
G
1

This can be caused by your service on SERVER2 starting up and finishing its initialization before MSMQ is done initializing itself. The easiest way to test this is to restart the service hosting the WCF MSMQ endpoint. If the WCF service is hosted in IIS, perhaps bouncing the app pool will do the same thing, but I do not know for sure -- I've never dealt with an IIS hosted MSMQ endpoint.

If restarting the service fixes your problem and your own service is a Windows service, you can then add MSMQ as a dependency to your own service so that it will delay its startup until MSMQ is ready. This answer on Server Fault describes how to do it. Incidentally, the service you want to depend on is called "Message Queueing"

Glans answered 10/10, 2014 at 14:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.