title: Relative path to import unmanaged DLL in C#
body: <p>I want to import a C++ DLL in my C# code. </p>
  
  <p>It works great using an absolute path pointing directly to this library, but I can't make it works using a relative path. </p>
  
  <p>The code that works is :</p>
  
  <pre><code>using System.Runtime.InteropServices;
  
  [...]
  
  [DllImport(@"C:\full\path\to\LibraryName.dll",
                  EntryPoint = "?export@symbol",
                  CallingConvention = CallingConvention.Cdecl)]
              public static extern IntPtr functionName(string param);
  </code></pre>
  
  <p>Note that I don't have a Visual Studio project to use and add references to. I am just adding a functionality to an existing (and working) .NET application by adding a new .aspx.cs page which is called somewhere within the app via the corresponding .aspx page.</p>
  
  <p>The application is currently deployed on IIS 7.5 hosted on a Windows Server 2008 R2.</p>
  
  <p>This may be a duplicate of these issues, but it didn't work for me. : <a href="https://stackoverflow.com/questions/9256901/relative-path-to-unmanaged-dll">Relative path to unmanaged DLL</a>
  <a href="https://stackoverflow.com/questions/8836093/how-can-i-specify-a-dllimport-path-at-runtime">How can I specify a [DllImport] path at runtime?</a></p>
  
  <p>Any new ideas compared to the posts mentioned above ?</p>