-1

I'm currently working on an Avalonia UI project where I need to call a function from a custom DLL using the DllImport attribute. However, I'm encountering an issue where I'm getting the error message:

System.EntryPointNotFoundException: 'Unable to find an entry point named 'GiveMeNumber' in DLL 'LibraryAdd'.'

Here's the relevant code snippet from my Avalonia UI project:

[DllImport(@"LibraryAdd", EntryPoint = "GiveMeNumber", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int GiveMeNumber();

private void PointerPressed(object sender, PointerPressedEventArgs e)
{
GiveMeNumber();
}

I've verified that the DLL "LibraryAdd.dll" exists in the same directory as my executable. The function GiveMeNumber is supposed to be exported from the DLL, but it seems that my code is unable to find the entry point.

What could be causing this issue? How can I resolve it and successfully call the GiveMeNumber function from my Avalonia UI application?

I would greatly appreciate any insights or solutions to this problem. Thank you in advance for your help!

Zain Samdani
  • 1
  • 1
  • 4
  • What library/DLL are you using? It is possible to share the DLL and it's documentation? One common issue might be that you forgotten to include the class name in EntryPoint, but there are other possible issues as well. – WQYeo Aug 07 '23 at 14:27
  • Is avalonia in any way related to your native DLL or your issues? Have you tried creating a minimal reproducible example in a console program? – JonasH Aug 07 '23 at 14:49
  • **@WQYeo** In my application, I am using a custom DLL named "LibraryAdd" that contains some unmanaged C++ code. The DLL includes a function named GiveMeNumber, which I can access successfully in a Console Application. However, when I try to call the same function from my Avalonia UI application, I encounter the Error – Zain Samdani Aug 08 '23 at 05:09

0 Answers0