Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entry Point Not Found Exception

I'm trying to use a C++ unmanaged dll in a C# project and I'm getting an error when trying to call a function that says that entry point cannot be found.

public class Program
{

    static void Main(string[] args)
    {
        IntPtr testIntPtr = aaeonAPIOpen(0);            
        Console.WriteLine(testIntPtr.ToString());
    }

    [DllImport("aonAPI.dll")]
    public static extern unsafe IntPtr aaeonAPIOpen(uint reserved);
}

Here is the dumpbin for the function:

5    4 00001020 ?aaeonAPIOpen@@YAPAXK@Z

I changed the dll import to [DllImport("aonAPI.dll", EntryPoint="?aaeonAPIOpen")] and [DllImport("aonAPI.dll", EntryPoint="_aaeonAPIOpen")] and no luck.

like image 514
Robert Avatar asked Aug 18 '10 18:08

Robert


1 Answers

Using the undname.exe utility, that symbol demangles to

 void * __cdecl aaeonAPIOpen(unsigned long)

Which makes the proper declaration:

    [DllImport("aonAPI.dll", EntryPoint="?aaeonAPIOpen@@YAPAXK@Z", 
        ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
    public static extern IntPtr aaeonAPIOpen(uint reserved);
like image 80
Hans Passant Avatar answered Sep 30 '22 21:09

Hans Passant