libimobiledevice-win32 / imobiledevice-net

.NET (C#, VB.NET,...) bindings for libimobiledevice
GNU Lesser General Public License v2.1
299 stars 77 forks source link

System.DllNotFoundException: imobiledevice on macOS #139

Closed danielgestwa closed 4 years ago

danielgestwa commented 4 years ago

Hi, I am using imobiledevice library to connect with iOS device through sockets. Under Windows everything works like a charm, but under macOS Catalina I have following error:

System.DllNotFoundException: imobiledevice assembly: type: member:(null) at (wrapper managed-to-native) iMobileDevice.iDevice.iDeviceNativeMethods.idevice_get_device_list(intptr&,int&) at iMobileDevice.iDevice.iDeviceNativeMethods.idevice_get_device_list (System.Collections.ObjectModel.ReadOnlyCollection1[System.String]& devices, System.Int32& count) [0x0000d] in D:\a\1\s\imobiledevice-net\iDevice\iDeviceNativeMethods.Extensions.cs:34 at iMobileDevice.iDevice.iDeviceApi.idevice_get_device_list (System.Collections.ObjectModel.ReadOnlyCollection1[System.String]& devices, System.Int32& count) [0x00000] in D:\a\1\s\imobiledevice-net\iDevice\iDeviceApi.cs:130 at UsbIphoneCommunication.PcSocketCommunication.Communicate () [0x00028] in /Users/dan/Programs/UsbIphoneCommunication/PcSocketCommunication.cs:28 at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/thread.cs:74 at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:968 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:910 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:899 at System.Threading.ThreadHelper.ThreadStart () [0x00008] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/thread.cs:111 [ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: imobiledevice assembly: type: member:(null) at (wrapper managed-to-native) iMobileDevice.iDevice.iDeviceNativeMethods.idevice_get_device_list(intptr&,int&) at iMobileDevice.iDevice.iDeviceNativeMethods.idevice_get_device_list (System.Collections.ObjectModel.ReadOnlyCollection1[System.String]& devices, System.Int32& count) [0x0000d] in D:\a\1\s\imobiledevice-net\iDevice\iDeviceNativeMethods.Extensions.cs:34 at iMobileDevice.iDevice.iDeviceApi.idevice_get_device_list (System.Collections.ObjectModel.ReadOnlyCollection1[System.String]& devices, System.Int32& count) [0x00000] in D:\a\1\s\imobiledevice-net\iDevice\iDeviceApi.cs:130 at UsbIphoneCommunication.PcSocketCommunication.Communicate () [0x00028] in /Users/dan/Programs/UsbIphoneCommunication/PcSocketCommunication.cs:28 at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/thread.cs:74 at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:968 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:910 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:899 at System.Threading.ThreadHelper.ThreadStart () [0x00008] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-08/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/thread.cs:111

It looks like dll is missing, but I already added macOS target to my iMobileDevice-net.targers, and build returns osx-64 folder with all files. It still throwns error. Anybody know the solution?

qmfrederik commented 4 years ago

@danielgestwa Is this on Mono?

danielgestwa commented 4 years ago

@qmfrederik I am using Visual Studio for mac and Unity Engine, so yes - this is Mono.

qmfrederik commented 4 years ago

@danielgestwa So the short story is that I've never tested this on Mono. We use imobiledevice-net extensively on macOS & .NET Core, though.

In your case, I think it may suffice to just copy the contents of osx-x64 to your app folder (the same folder as where imobiledevice-net.dll is located).

If that works, we may try to update https://github.com/libimobiledevice-win32/imobiledevice-net/blob/master/iMobileDevice-net/build/net45/iMobileDevice-net.targets to do the copying as part of the build.

Alternatively, a DllMap configuration or a manual call to dlopen may also work.

Let me know if any of that works.

danielgestwa commented 4 years ago

@qmfrederik As you said, this is working 😄 I was copying whole osx-x64 folder to place where imobiledevice-net.dll was placed and that caused me an error. When I copied CONTENTS of osx-x64, then it worked. This was unexpected, because on Windows I copied whole win-x64 folder and that worked. Anyway, thank you so much, I saved a lot of time!

rauleteee commented 2 years ago

Hi! I have the same issue, did you finally fix it and how? Thank you in advance! Im running it on VS2019 in osx-x64

danielgestwa commented 2 years ago

A

Hi! I have the same issue, did you finally fix it and how? Thank you in advance! Im running it on VS2019 in osx-x64

As I said in previous message, I had an issue with directory tree. On Mac you should copy content of x64 dll dir, not dir with content. After that everything was working fine.