2009-12-18 33 views
9

Tengo un servicio WCF alojado en un servicio de Windows que establecí en Automático para que se inicie automáticamente cuando se abre el servidor. El servicio es endpoint respaldado por MSMQ.El servicio WCF respaldado por MSMQ alojado en un servicio de Windows falla al iniciar

Cuando inicio el servicio manualmente, todo está bien. Sin embargo, cuando el servicio se inicia en el arranque, recibo una excepción 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 --- 

Parece que el MSMQ no está listo para ser utilizado antes de que comience el servicio ... ¿hay una solución para esto?

Respuesta

7

Necesita agregar una dependencia en MSMQ en su host de servicio WCF. Esto se puede hacer en el instalador del servicio:

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

Si no está utilizando un instalador de servicio, también se puede añadir la dependencia de MSMQ para su servicio mediante la edición del registro de Windows, como se describe en "Microsoft Support: How to delay loading of specific services".

+0

gracias! ¡googlear ese mensaje de excepción resultó infructuoso! – puffpio

Cuestiones relacionadas