9

自動に設定したWindowsサービスでホストされているWCFサービスがあるため、サーバーが起動すると自動的に開始されます。サービスはエンドポイントであり、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を使用する準備ができていないようです...これに対する解決策はありますか?

4

1 に答える 1

7

WCFサービスホストにMSMQへの依存関係を追加する必要があります。これは、サービスインストーラで実行できます。

ServiceInstaller serviceInstaller = new ServiceInstaller();
// Adding this property to your ServiceInstaller forces 
// your service to start after MSMQ.
serviceInstaller.ServicesDependedOn = new string[] { "MSMQ" };

サービスインストーラーを使用していない場合は、「Microsoftサポート:特定のサービスの読み込みを遅らせる方法」で説明されているように、Windowsレジストリを編集してサービスのMSMQ依存関係を追加することもできます。

于 2009-12-18T18:39:13.480 に答える