Prevent application from starting if MSMQ is not installed

I am using MSMQ in my .NET application. If MSMQ is installed but does not work, it can be processed.

But how to prevent a crash on startup if the MSMQ function is not installed on the local computer?

0
windows messages msmq
source share
2 answers

This is not very, but I used it 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); } 
+3
source share
+2
source share

All Articles