Forum Xamarin.iOS

DllNotFoundException when trying to call native code


I'm trying to generate the correct API definitions to use some code in Go compiled as a framework (writing a frontend for Rclone). The static library is called libMobile.a. I'm currently getting a DllNotFoundException at run time when trying to call methods on it.

Here's what I've done:

  1. Use sharpie to generate the definitions.
  2. Create a new binding project in Visual Studio on windows. Copy the binary out from the framework to the binding project's directory, renaming it to "libmobile.a". Then I chose "add existing item" to add it to the binding project.
  3. Replace the prefilled definitions with the following:

Structs.cs (probable cause of error)

using System.Runtime.InteropServices;
using Foundation;

namespace rclone
    public static class CFunctions
        // extern void MobileInit ();
        public static extern void MobileInit();

        // extern NSString * MobileListRemotes ();
        public static extern NSString MobileListRemotes();

        // extern void MobileLoadConfig (NSString *path);
        public static extern void MobileLoadConfig(NSString path);
  1. Add the following to AssemblyInfo.cs in the xamarin.ios project to try to link "libMobile.a":
using System;
using ObjCRuntime;

[assembly: LinkWith ("libMobile.a", LinkTarget.ArmV7 | LinkTarget.Simulator, ForceLoad = true)]

When launching the app, it crashes with a DllNotFoundException, stating that "libMobile.a" is not found.

What did I miss? I can also attach the framework and solution, if that helps.


Sign In or Register to comment.