DllNotFoundException when trying to call native code

Hi,

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 ();
        [DllImport("libMobile.a")]
        public static extern void MobileInit();

        // extern NSString * MobileListRemotes ();
        [DllImport("libMobile.a")]
        public static extern NSString MobileListRemotes();

        // extern void MobileLoadConfig (NSString *path);
        [DllImport("libMobile.a")]
        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.

Answers

Sign In or Register to comment.