title: C# GetProcAddress Returns Zero
body: <p>For some reason, whenever my C# .NET 2.0 application makes a call to <code>GetProcAddress</code> it always returns zero.</p>
  
  <pre><code>public class MyClass
  {
      internal static class UnsafeNativeMethods
      {
          [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
          internal static extern IntPtr LoadLibrary(string lpFileName);
  
          [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
          internal static extern bool SetDllDirectory(string lpPathName);
  
          [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
          internal static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
      }
  
      private void MyFunc()
      {
          IntPtr _dllHandle;
          IntPtr _fptr;
          string _fullPath = ".\\mydll.dll";
          string _procName = "MyDllFunc";
  
          _dllHandle = UnsafeNativeMethods.LoadLibrary(_fullPath);
          _fptr = UnsafeNativeMethods.GetProcAddress(_dllHandle, _procName); // &lt;-- Always returns zero.
      }
  }
  </code></pre>
  
  <p>I'm sure the function name is spelled correctly, and <code>_fullPath</code> is presumably correct because <code>_dllHandle</code> is always assigned a non-zero value.  Any insight you may be able to provide is appreciated.  Thanks.</p>