我有一个 WCF 服务托管在我设置为自动的 Windows 服务中,因此它会在服务器启动时自动启动。该服务的端点由 MSMQ 支持。
当我手动启动服务时,一切都很好。但是当服务在启动时启动时,我得到一个 MSMQ 异常:
System.TypeInitializationException: The type initializer for
'System.ServiceModel.Channels.Msmq' threw an exception. --->
System.ServiceModel.MsmqException: The version check failed with the error:
'The Message Queuing service is not available (-1072824309, 0xc00e000b)'. The
version of MSMQ cannot be detected All operations that are on the queued channel
will fail. Ensure that MSMQ is installed and is available.
at System.ServiceModel.Channels.MsmqQueue.GetMsmqInformation
(Version& version, Boolean& activeDirectoryEnabled)
at System.ServiceModel.Channels.Msmq..cctor()
--- End of inner exception stack trace ---
似乎在服务启动之前 MSMQ 还没有准备好使用……有解决方案吗?