DllImport Help

M

MDB

Hello All, I am tring to call a function within a third party DLL and keep
getting the following error:

MissingMethodException

According to the dumpbin results, there is a function calle IBT_on however,
I can't seem to access it.
ordinal hint rva name
1 0 000025SC ?IBT_on@@YAIXZ

Here is what my code looks like that is importing the DLL:

[DllImport("IBT.dll")]
private static extern Int32 IBT_on();

Dll name is IBT.dll

Also, the dll is located in my windows directory and my program directory.

Anyone know what I am doing wrong?
 
M

MDB

Yes,

Here is what that looks like:

private void button2_Click(object sender, System.EventArgs e)
{
try
{
IBT_on();
}
catch (Exception xxx)
{
MessageBox.Show(xxx.Message.ToString());
}
}




Duncan Mole said:
Are you calling it on an event?

MDB said:
Hello All, I am tring to call a function within a third party DLL and keep
getting the following error:

MissingMethodException

According to the dumpbin results, there is a function calle IBT_on however,
I can't seem to access it.
ordinal hint rva name
1 0 000025SC ?IBT_on@@YAIXZ

Here is what my code looks like that is importing the DLL:

[DllImport("IBT.dll")]
private static extern Int32 IBT_on();

Dll name is IBT.dll

Also, the dll is located in my windows directory and my program directory.

Anyone know what I am doing wrong?
 
P

Peter Foot [MVP]

Since the function name is mangled, you'll need to specify the ordinal or
name explicitly using the EntryPoint member of the DllImport attribute e.g.
[DllImport("IBT.dll", EntryPoint="#1")]
private static extern Int32 IBT_on();

or

[DllImport("IBT.dll", EntryPoint="?IBT_on@@YAIXZ")]
private static extern Int32 IBT_on();

Peter
 
M

MDB

That did it. Thank you for your help!


Peter Foot said:
Since the function name is mangled, you'll need to specify the ordinal or
name explicitly using the EntryPoint member of the DllImport attribute e.g.
[DllImport("IBT.dll", EntryPoint="#1")]
private static extern Int32 IBT_on();

or

[DllImport("IBT.dll", EntryPoint="?IBT_on@@YAIXZ")]
private static extern Int32 IBT_on();

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

MDB said:
Hello All, I am tring to call a function within a third party DLL and keep
getting the following error:

MissingMethodException

According to the dumpbin results, there is a function calle IBT_on
however,
I can't seem to access it.
ordinal hint rva name
1 0 000025SC ?IBT_on@@YAIXZ

Here is what my code looks like that is importing the DLL:

[DllImport("IBT.dll")]
private static extern Int32 IBT_on();

Dll name is IBT.dll

Also, the dll is located in my windows directory and my program directory.

Anyone know what I am doing wrong?
 
C

Chris Tacke, eMVP

The other option is to actually use the name dumpbin gave you (including the
@@YAIXZ).

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
---
Principal Partner
OpenNETCF Consulting
www.OpenNETCF.com



MDB said:
That did it. Thank you for your help!


Peter Foot said:
Since the function name is mangled, you'll need to specify the ordinal or
name explicitly using the EntryPoint member of the DllImport attribute e.g.
[DllImport("IBT.dll", EntryPoint="#1")]
private static extern Int32 IBT_on();

or

[DllImport("IBT.dll", EntryPoint="?IBT_on@@YAIXZ")]
private static extern Int32 IBT_on();

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

MDB said:
Hello All, I am tring to call a function within a third party DLL and keep
getting the following error:

MissingMethodException

According to the dumpbin results, there is a function calle IBT_on
however,
I can't seem to access it.
ordinal hint rva name
1 0 000025SC ?IBT_on@@YAIXZ

Here is what my code looks like that is importing the DLL:

[DllImport("IBT.dll")]
private static extern Int32 IBT_on();

Dll name is IBT.dll

Also, the dll is located in my windows directory and my program directory.

Anyone know what I am doing wrong?
 
A

Alex Feinman [MVP]

I think the compiler would not agree to an identifier that starts with "?"
<g>

--
Alex Feinman
---
Visit http://www.opennetcf.org
Chris Tacke said:
The other option is to actually use the name dumpbin gave you (including the
@@YAIXZ).

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
---
Principal Partner
OpenNETCF Consulting
www.OpenNETCF.com



MDB said:
That did it. Thank you for your help!


Peter Foot said:
Since the function name is mangled, you'll need to specify the ordinal or
name explicitly using the EntryPoint member of the DllImport attribute e.g.
[DllImport("IBT.dll", EntryPoint="#1")]
private static extern Int32 IBT_on();

or

[DllImport("IBT.dll", EntryPoint="?IBT_on@@YAIXZ")]
private static extern Int32 IBT_on();

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

"MDB" <nospam> wrote in message
Hello All, I am tring to call a function within a third party DLL
and
keep
getting the following error:

MissingMethodException

According to the dumpbin results, there is a function calle IBT_on
however,
I can't seem to access it.
ordinal hint rva name
1 0 000025SC ?IBT_on@@YAIXZ

Here is what my code looks like that is importing the DLL:

[DllImport("IBT.dll")]
private static extern Int32 IBT_on();

Dll name is IBT.dll

Also, the dll is located in my windows directory and my program directory.

Anyone know what I am doing wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top