Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>We embed the unmanaged dlls into an assembly and then copy them out to the executing dll location (for web apps the shadow copy bin folder). This guarantees that the correct version is being run for a particular version of our app. Unfortunately this may not be doable (legal) depending on licensing terms for your various applications. In these cases, your best option is likely to use <a href="http://msdn.microsoft.com/en-us/library/ms684175%28VS.85%29.aspx" rel="nofollow noreferrer">LoadLibrary</a> to verify that the library is found, but beware of loading the wrong version (see also: <a href="http://en.wikipedia.org/wiki/DLL_hell" rel="nofollow noreferrer">DLL hell</a>); this may or may not be a problem you can even solve (for us, the only solution was embedding the dlls and extracting them from the assemblies where needed).</p> <p>Here is our code in question for the Sybase ASE ADO drivers:</p> <pre><code>public static class SybaseResourceExtractor { public static void ExtractSybaseDependencies() { ExtractSybaseDependency("QueryLibrary.Unmanaged.sybdrvado20.dll", "sybdrvado20.dll"); ExtractSybaseDependency("QueryLibrary.Unmanaged.msvcr80.dll", "msvcr80.dll"); ExtractSybaseDependency("QueryLibrary.Unmanaged.sybcsi_certicom_fips26.dll", "sybcsi_certicom_fips26.dll"); ExtractSybaseDependency("QueryLibrary.Unmanaged.sybcsi_core26.dll", "sybcsi_core26.dll"); ExtractSybaseDependency("QueryLibrary.Unmanaged.sbgse2.dll", "sbgse2.dll"); } /// &lt;summary&gt; /// Extracts a resource to a file. /// &lt;/summary&gt; /// &lt;param name="resourceName"&gt;Name of the resource.&lt;/param&gt; /// &lt;param name="filename"&gt;The filename including absolute path.&lt;/param&gt; static void ExtractSybaseDependency(string resourceName, string filename) { try { var assembly = Assembly.GetAssembly(typeof(AseConnection)); var executingAssembly = Assembly.GetExecutingAssembly(); filename = Path.GetDirectoryName(assembly.Location) + "\\" + filename; if (File.Exists(filename)) { File.Delete(filename); } if (!File.Exists(filename)) { using (Stream s = executingAssembly.GetManifestResourceStream(resourceName)) { using (var fs = new FileStream(filename, FileMode.Create)) { if (s == null) { throw new Exception("Failed to get resource stream for " + resourceName); } var b = new byte[s.Length]; s.Read(b, 0, b.Length); fs.Write(b, 0, b.Length); } } } } catch { //Doing nothing } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload