Check for native library in .NET managed code
<p>I have a .NET application written in C#. My application uses 3rd party libraries, which use 3rd party libraries, which in turn rely on the existence of sqlceme35.dll (Microsoft SSCE). Somewhere along the line the dependency on sqlceme35.dll is not being accounted for, and we've had a number of situations where my software has been installed on a computer without this library, the application appears to run fine for most functions, but crashes in a spectacular way with cryptic error messages when we get to the point when we try to call into sqlceme35.dll.</p>

<p>Even though we now know what the effects look like when the library isn't present, I would still like to be more proactive about detecting when the library is not available and giving the user a friendly error message "here is the problem, here is the solution".</p>

<p>The immediate question is: How do I detect, at runtime, the presence of the sqlceme35.dll library?</p>

<p>The larger question is: How do I detect, at runtime, the presence of any arbitrary .dll file, whether it be a native code or a managed code library?</p>
