Using C DLL in C#

G

Guest

I have a C DLL and I need to use in C# i tried to load and use the function
as following but exception generated with error
An unhandled exception of type 'System.EntryPointNotFoundException' occurred
in CDicLib.exe

Additional information: Unable to find an entry point named in_wn in DLL
E:\Dictionary\CDicLib\Lib\tcl84.dll.


[DllImport("E:\\Dictionary\\CDicLib\\Lib\\tcl84.dll")]
public static extern int in_wn(string searchstr, int pos);


in main funciton in c#
i called in_wn("asdasdasdasdsad",3");//exception occured
 
R

Richard Blewett [DevelopMentor]

Raed Sawalha said:
I have a C DLL and I need to use in C# i tried to load and use the function
as following but exception generated with error
An unhandled exception of type 'System.EntryPointNotFoundException'
occurred
in CDicLib.exe

Additional information: Unable to find an entry point named in_wn in DLL
E:\Dictionary\CDicLib\Lib\tcl84.dll.


[DllImport("E:\\Dictionary\\CDicLib\\Lib\\tcl84.dll")]
public static extern int in_wn(string searchstr, int pos);


in main funciton in c#
i called in_wn("asdasdasdasdsad",3");//exception occured

Well its saying there is no function called in_wn exported from the dll. Are
you sure thats the right entry point name? You can check by running

dumpbin /exports E:\Dictionary\CDicLib\Lib\tcl84.dll

from the command line

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
 
G

Guest

Specify the EntryPoint in DllImport Attribute as the method which you are
trying to call from the .NET code.

like this,
[DllImport("E:\\Dictionary\\CDicLib\\Lib\\tcl84.dll", EntryPoint =
"MethodNameInDll")]
public static extern int in_wn(string searchstr, int pos);

Hope this would help you...

Regards,
Dhans
 

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