title: System.DllNotFoundException: Unable to load DLL with dotnet core
body: <p>I've been tasked with calling openzwave from dotnet core on linux and i'm having issues with dotnet core loading my c++ library. Essentially any time i touch the openzwave library I get a dll not found exception.
  here's my program.cs </p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Runtime.InteropServices;
      using System.Threading.Tasks;
  
      namespace MinOZWDotNet
      {
          public class Program
          {
  
              [DllImport("MinOZW")]
              public static extern int Init();
  
              [DllImport("MinOZW")]
              public static extern int Free();
  
              public static void Main(string[] args)
              {
                  Console.WriteLine("Calling Init");
                  var val= Init();
                  Console.WriteLine($"retval= {val}");
  
                  while (true)
                  {
  
                      if (Console.KeyAvailable)
                      {
  
                          ConsoleKeyInfo key = Console.ReadKey();
  
                          if (key.Key == ConsoleKey.Escape)
                          {
                              Console.WriteLine("Exit");
                              break;
                          }
                      }
                  }
  
                  Console.WriteLine("Calling Free");
                  val = Free();
                  Console.WriteLine($"retval = {val}");
  
              }
          }
      }
  </code></pre>
  
  <p>heres a version of the .so which works</p>
  
  <pre><code>#ifdef __GNUC__
          #define EXPORT extern "C"
          #define CC
  #else
          #define EXPORT extern "C" __declspec (dllexport)
          #define CC __stdcall
  #endif
  
  #ifdef __GNUC__
  
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  #include "Defs.h"
  
  #else
  
  #include "Windows.h"
  
  #endif
  
  
  
  EXPORT int CC Init() {
  
          return 0;
  }
  
  EXPORT int CC Free() {
  
          return 0;
  }
  </code></pre>
  
  <p>heres the version which is giving me the error</p>
  
  <pre><code>#ifdef __GNUC__
          #define EXPORT extern "C"
          #define CC
  #else
          #define EXPORT extern "C" __declspec (dllexport)
          #define CC __stdcall
  #endif
  
  #ifdef __GNUC__
  
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  #include "Defs.h"
  
  #else
  
  #include "Windows.h"
  
  #endif
  
  
  #include "Options.h"
  #include "Manager.h"
  #include "Driver.h"
  #include "Node.h"
  #include "Group.h"
  #include "Notification.h"
  #include "value_classes/ValueStore.h"
  #include "value_classes/Value.h"
  #include "value_classes/ValueBool.h"
  #include "platform/Log.h"
  
  using namespace OpenZWave;
  
  
  EXPORT int CC Init() {
          Manager::Create();
          return 0;
  }
  
  EXPORT int CC Free() {
          Manager::Destroy();
          return 0;
  }
  </code></pre>
  
  <p>both openzwave and this lib are on the expected path. 
  N.B when compiled on windows this all works.
  <a href="https://github.com/OpenZWave/open-zwave/tree/master/cpp/examples/MinOZW" rel="nofollow noreferrer">openZwave on github</a></p>