Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DllNotFoundException #1

Closed
keesschollaart81 opened this issue Oct 30, 2018 · 3 comments

Comments

@keesschollaart81
Copy link

@keesschollaart81 keesschollaart81 commented Oct 30, 2018

Hi,

I'm trying the 3.2.0 version of your package and it's giving me a System.DllNotFoundException

Steps to reproduce:
dotnet new console
dotnet add package H3
in the Main method:

using System;
using H3Standard;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var h3 = H3.GeoToH3(51.9914692, 5.0760207, 5);

            Console.WriteLine("Hello World!");
        }
    }
}

dotnet build > Compiles succesfully
dotnet run > results in:

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'h3lib.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at H3Standard.H3.geoToH3(H3GeoCoord& g, Int32 res)
   at H3Standard.H3.GeoToH3(Double latitude, Double longitude, Int32 resolution)
   at test.Program.Main(String[] args) in C:\projects\test\Program.cs:line 10

This is the same if I change the TargetFramework from netcoreapp2.1 to net472

My dotnet --info is

.NET Core SDK (reflecting any global.json):
 Version:   2.1.400
 Commit:    8642e60a0f

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.400\

Host (useful for support):
  Version: 2.1.2
  Commit:  811c3ce6c0

.NET Core SDKs installed:
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.400 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Update: I also tried it on a MacBook with the following dotnet --info but this gives the same error:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.301
 Commit:    59524873d6

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.301/

Host (useful for support):
  Version: 2.1.1
  Commit:  6985b9f684

.NET Core SDKs installed:
  1.0.0-preview1-002697 [/usr/local/share/dotnet/sdk]
  1.0.0-preview2-003148 [/usr/local/share/dotnet/sdk]
  1.0.0-preview2-1-003177 [/usr/local/share/dotnet/sdk]
  1.0.4 [/usr/local/share/dotnet/sdk]
  2.0.0-preview1-005977 [/usr/local/share/dotnet/sdk]
  2.0.0 [/usr/local/share/dotnet/sdk]
  2.1.4 [/usr/local/share/dotnet/sdk]
  2.1.301 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.0-rc2-3002697 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0-preview1-002111-00 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
@TheSpy

This comment has been minimized.

Copy link

@TheSpy TheSpy commented Feb 26, 2019

Hey, you need to call H3.InstanciateNativeLibrary(); to get dll copied to the output folder before calling GeoToH3

@keesschollaart81

This comment has been minimized.

Copy link
Author

@keesschollaart81 keesschollaart81 commented Feb 26, 2019

Cool, I'm not able any more to try it out but I'm sure the next one reading this will appreciate your reply/solution! 👍

@ArnaudSwail

This comment has been minimized.

Copy link
Collaborator

@ArnaudSwail ArnaudSwail commented Feb 26, 2019

Hi, thanks every one to point on this awkward way of managing nuget distribution of this package.

After a battle of a few days, using nuget reference docs and stackoverflow , I found that the embedded resource proposed by Ondrej Janacek was the only one working with nuget in a single pack. The dll is oversized with the native dll as a resource, and you have to call H3.InstanciateNativeLibrary() once (and never in prod and so on...).

After browsing of a few better packed groups of managed and dynamic library, it seems that the clean way to go is to create two separate packages, one for managed libraries and one for native ones, which seems fair after all...

Uber core library is updating quite often these days, I'll pack a new version in the next weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.