user1502203
user1502203

Reputation: 1

Unmanaged dll in C#.net having entrypoint error

I have a dll called OMGICardDll.dll that communicate with a usb plugin Smartcard device to read the data from card

Here is the code That I Used :

public partial class Form1 : Form
{
    [DllImport("OMGICardDll",EntryPoint="ReadName",ExactSpelling=true, CallingConvention = CallingConvention.StdCall,SetLastError=false)]
   public  static extern string ReadName();
  //Form1 fm = new Form1();
    public Form1()
    {
        InitializeComponent();
    }

  private void Form1_Load(object sender, EventArgs e)
  {

  }

  private void btnSave_Click(object sender, EventArgs e)
  {

      txtName.Text = ReadName();
  }


}

When I clicked save button I found System.EntryPointNotFoundException

Upvotes: 0

Views: 153

Answers (1)

reuben
reuben

Reputation: 3370

The error may indicate that OMGICardDll.dll could be found and loaded, but that the function ReadName does not exist in it or is not exported from it.

Can you verify that the routine is spelled precisely like that? And is exported? (And isn't actually called ReadNameA or ReadNameW?)

Upvotes: 1

Related Questions