1

I have a dll that was written in ada, and I'd like to use it in a Unity project, with C#. The problem is that I'm getting an EntryPointNotFoundException error.

For example, the ada code contains a function Initialize_Test, that returns a long. From what I can tell it is exporting this properly to interface with C languages and avoid name mangling:

pragma Export (C, Initialize_Test, "Initialize_Test");

and then in my c# I have:

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

public class menuControl : MonoBehaviour {

[DllImport ("test_dll", EntryPoint="Initialize_Test" )]
public static extern int Initialize_Test();

    void Start () {
        Debug.Log(Initialize_Test () );
    }
}

It gets as far as Initialize_Test(), under the . according to http://www.mono-project.com/docs/advanced/pinvoke/#marshaling, that means that it's finding the dll alright (it was placed in the plugins folder) but cannot find the function "Initialize_Test".

http://docs.go-mono.com/?link=T%3aSystem.TypeLoadException has some suggestions as to what could be causing this, but none of them look like they apply here. I suppose the only thing left to do is to just get the mangled names with dumpbin.exe, but I feel like there should be a proper way to do this.

The person who compiled the dll assures me that other people have used it successfully, but none of them were using Unity, much less C#. I'm afraid that there's just something about Ada that makes it incompatible, I saw a bit in Unity's documentation that suggested it is simply unable to accept native code generated from certain compilers.

Steven
  • 166,672
  • 24
  • 332
  • 435
pdonk
  • 11
  • 2
  • Intermediate steps : does a simple C program calling Initialize_Test work? Can you call (from C#) a function from a DLL written in C? These may indicate which end has a problem. –  May 20 '15 at 15:47
  • I wrote an extremely simple dll that only contains extern "C" int DllExport Initialize_Test() { return 5; }, and I was able to call it from C# with no problem. – pdonk May 20 '15 at 18:34

1 Answers1

0

Well, I had to run dumpbin.exe on the dll, and was able to find its exports. For example, "Initialize_Test" should have been "initialize_test@0".

With that said, I'm still having problems using the functions, ada types don't seem to match with c# types at all, but I guess that's a different question.

pdonk
  • 11
  • 2