I'm using MSMQ in my .NET application. If MSMQ installed but not running - it can be handled.
But how to prevent crash on start up if MSMQ feature not installed on local machine ?
I'm using MSMQ in my .NET application. If MSMQ installed but not running - it can be handled.
But how to prevent crash on start up if MSMQ feature not installed on local machine ?
It's not pretty, but I've used this before with some success:
public static bool IsMsmqInstalled
{
get
{
try
{
IntPtr result = NativeMethods.LoadLibrary("Mqrt.dll");
return (result != IntPtr.Zero);
}
catch (Exception)
{
return false;
}
}
}
public sealed class NativeMethods
{
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern IntPtr LoadLibrary(string lpFileName);
}
Here's my blog:
© 2022 - 2024 — McMap. All rights reserved.