Native dll can't be found .Net Core, but can be found .Net Framework


I have a .Net Standard project which references a native dll, which I've built for all targets.

I then published the project on a private nuget feed, using a nuspec along the lines of:

<?xml version="1.0" encoding="utf-8"?>
    <file src="..\bin\NetStandard20\Managed.dll" target="lib\netstandard2.0" />
    <file src="..\bin\NetStandard20\Managed.xml" target="lib\netstandard2.0" />
    <file src="..\bin\2017\Win32\Release\Native.dll" target="build\netstandard2.0\x86" />
    <file src="..\bin\2017\x64\Release\Native.dll" target="build\netstandard2.0\x64" />
    <file src="..\bin\2016\linux-x64\Release\Native.dll" target="build\netstandard2.0\linux-x64" />
    <file src="..\bin\2016\osx-x64\Release\Native.dll" target="build\netstandard2.0\osx-x64" />
    <file src="shared\Core\build\Managed.targets" target="build\netstandard2.0\Managed.targets" />
    <file src="shared\Core\lib\Managed.config" target="lib\netstandard2.0" />

Now when I install that nuget package to a .Net Core App running on windows 10, and I run the app targeting x86 I get an error:

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'Native.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

The strange thing is, that if I change the app to a .Net Framework app, targeting the same architecture, everything runs fine.

Does anyone have any ideas why this might be?

asked on Stack Overflow Jan 3, 2019 by Yair Halberstadt • edited Jan 3, 2019 by πάντα ῥεῖ

1 Answer


I guess, there is a conflict in your project about which CPU architecture to target. The line win7-x86 instructs NuGet to use the x86 version of Native.DLL and AnyCPU instructs the app to compile as AnyCPU, which means the process may run as x64. This mismatch is likely the source of the error.

answered on Stack Overflow Jan 3, 2019 by NativeKepler11

User contributions licensed under CC BY-SA 3.0