473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

[Urgent] Import other DLL and use it's function in C#

Dear All

I have register a 3rd's DLL into my pc, and I can create an instance by
using CreateObject in ASP page, eg.
set obj = CreateObject("3rdDLLName");

And it contains several methods such as
string MyMethod(string)
string YourMethod(string)
string NoMethod(string)

Because of some reason, I need using this DLL's function in my C# program,
so I do following
[DllImport("C:\\dll\\3rdDLLName.dll")]
public static extern string MyMethod(string content);

But when I call such method in my program, it throw
Unhandled Exception: System.EntryPointNotFoundException: Unable to find an
entry
point named MyMethod in DLL C:\dll\3rdDLLName.dll

My question is
1. Do the method call in ASP is the EntryPorint of the Dll?
2. How to know the EntryPoint of the Dll?

Many Thanks
Jul 18 '06 #1
6 3948
You may run "dumpbin /exports C:\dll\3rdDLLName.dll" to see if it has a
properly exported function.

But from your description, it's more likely to be a COM library, which you
can directly "Add reference" if it contains the linking information, or you
can find the correct .tlb file for it.
(if it is the case, you'll see "DllRegisterServer" in one of the exported
functions)

"PenguinPig" <企鵝豬大爺@公司撰寫於郵件新聞:%2****************@ TK2MSFTNGP03.phx.gbl...
Dear All

I have register a 3rd's DLL into my pc, and I can create an instance by
using CreateObject in ASP page, eg.
set obj = CreateObject("3rdDLLName");

And it contains several methods such as
string MyMethod(string)
string YourMethod(string)
string NoMethod(string)

Because of some reason, I need using this DLL's function in my C# program,
so I do following
[DllImport("C:\\dll\\3rdDLLName.dll")]
public static extern string MyMethod(string content);

But when I call such method in my program, it throw
Unhandled Exception: System.EntryPointNotFoundException: Unable to find an
entry
point named MyMethod in DLL C:\dll\3rdDLLName.dll

My question is
1. Do the method call in ASP is the EntryPorint of the Dll?
2. How to know the EntryPoint of the Dll?

Many Thanks


Jul 18 '06 #2
Hi,

There are two way to consume native code and they are different, there is
one called P/invoke which allow you to consume native win DLL, it's what
you tried to do in your code. It does only work for win32 dlls.
The other mechanism is COM interop. this allow you to consume COM objects in
..NET and even as both sounds similar they are WAY different. You consume COM
objets by creating a Runtime Callable Wrapper . It can be done simple by
selecting "Add Reference" in VS and selecting the COM tab. It will generate
all the needed structure for you.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"PenguinPig" <企鵝豬大爺@公司wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Dear All

I have register a 3rd's DLL into my pc, and I can create an instance by
using CreateObject in ASP page, eg.
set obj = CreateObject("3rdDLLName");

And it contains several methods such as
string MyMethod(string)
string YourMethod(string)
string NoMethod(string)

Because of some reason, I need using this DLL's function in my C# program,
so I do following
[DllImport("C:\\dll\\3rdDLLName.dll")]
public static extern string MyMethod(string content);

But when I call such method in my program, it throw
Unhandled Exception: System.EntryPointNotFoundException: Unable to find an
entry
point named MyMethod in DLL C:\dll\3rdDLLName.dll

My question is
1. Do the method call in ASP is the EntryPorint of the Dll?
2. How to know the EntryPoint of the Dll?

Many Thanks


Jul 18 '06 #3
Thanks Ignacio Machin~
But how to add reference if i haven't visual studio...
Thanks

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.uswrote
in message news:e4**************@TK2MSFTNGP04.phx.gbl...
Hi,

There are two way to consume native code and they are different, there is
one called P/invoke which allow you to consume native win DLL, it's what
you tried to do in your code. It does only work for win32 dlls.
The other mechanism is COM interop. this allow you to consume COM objects
in
.NET and even as both sounds similar they are WAY different. You consume
COM
objets by creating a Runtime Callable Wrapper . It can be done simple by
selecting "Add Reference" in VS and selecting the COM tab. It will
generate
all the needed structure for you.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"PenguinPig" <企鵝豬大爺@公司wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Dear All

I have register a 3rd's DLL into my pc, and I can create an instance by
using CreateObject in ASP page, eg.
set obj = CreateObject("3rdDLLName");

And it contains several methods such as
string MyMethod(string)
string YourMethod(string)
string NoMethod(string)

Because of some reason, I need using this DLL's function in my C#
program,
so I do following
[DllImport("C:\\dll\\3rdDLLName.dll")]
public static extern string MyMethod(string content);

But when I call such method in my program, it throw
Unhandled Exception: System.EntryPointNotFoundException: Unable to find
an
entry
point named MyMethod in DLL C:\dll\3rdDLLName.dll

My question is
1. Do the method call in ASP is the EntryPorint of the Dll?
2. How to know the EntryPoint of the Dll?

Many Thanks


Jul 18 '06 #4
Dear Lau

I cannot locate the file dumpbin, where you got this file?
Also, if i haven't VS.Net, how to reference such dll in my C# code?

ThankS

"Lau Lei Cheong" <le****@yehoo.com.hkwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
You may run "dumpbin /exports C:\dll\3rdDLLName.dll" to see if it has a
properly exported function.

But from your description, it's more likely to be a COM library, which you
can directly "Add reference" if it contains the linking information, or
you
can find the correct .tlb file for it.
(if it is the case, you'll see "DllRegisterServer" in one of the exported
functions)

"PenguinPig" <企鵝豬大爺@公司撰寫於郵件新聞
:%2****************@TK2MSFTNGP03.phx.gbl...
Dear All

I have register a 3rd's DLL into my pc, and I can create an instance by
using CreateObject in ASP page, eg.
set obj = CreateObject("3rdDLLName");

And it contains several methods such as
string MyMethod(string)
string YourMethod(string)
string NoMethod(string)

Because of some reason, I need using this DLL's function in my C#
program,
so I do following
[DllImport("C:\\dll\\3rdDLLName.dll")]
public static extern string MyMethod(string content);

But when I call such method in my program, it throw
Unhandled Exception: System.EntryPointNotFoundException: Unable to find
an
entry
point named MyMethod in DLL C:\dll\3rdDLLName.dll

My question is
1. Do the method call in ASP is the EntryPorint of the Dll?
2. How to know the EntryPoint of the Dll?

Many Thanks


Jul 18 '06 #5
Hi

you can create a proxy class using tlbimp tool.....

tlbimp xx.dll /out:xx_dotnetproxy.dll

here xx.dll is your COM component... now you will get a .net proxy assembly...

Veera.

"PenguinPig" wrote:
Thanks Ignacio Machin~
But how to add reference if i haven't visual studio...
Thanks

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.uswrote
in message news:e4**************@TK2MSFTNGP04.phx.gbl...
Hi,

There are two way to consume native code and they are different, there is
one called P/invoke which allow you to consume native win DLL, it's what
you tried to do in your code. It does only work for win32 dlls.
The other mechanism is COM interop. this allow you to consume COM objects
in
.NET and even as both sounds similar they are WAY different. You consume
COM
objets by creating a Runtime Callable Wrapper . It can be done simple by
selecting "Add Reference" in VS and selecting the COM tab. It will
generate
all the needed structure for you.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"PenguinPig" <瞼繪Z翻瞻j繚@瞻翻瞼qwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Dear All
>
I have register a 3rd's DLL into my pc, and I can create an instance by
using CreateObject in ASP page, eg.
set obj = CreateObject("3rdDLLName");
>
And it contains several methods such as
string MyMethod(string)
string YourMethod(string)
string NoMethod(string)
>
Because of some reason, I need using this DLL's function in my C#
program,
so I do following
[DllImport("C:\\dll\\3rdDLLName.dll")]
public static extern string MyMethod(string content);
>
But when I call such method in my program, it throw
Unhandled Exception: System.EntryPointNotFoundException: Unable to find
an
entry
point named MyMethod in DLL C:\dll\3rdDLLName.dll
>
My question is
1. Do the method call in ASP is the EntryPorint of the Dll?
2. How to know the EntryPoint of the Dll?
>
Many Thanks
>
>


Jul 18 '06 #6
dumpbin is at Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\dumpbin.exe

Other parts answered by Ignacio and veera. :)

"Lau Lei Cheong" <le****@yehoo.com.hk撰寫於郵件新聞:ej************* *@TK2MSFTNGP03.phx.gbl...
You may run "dumpbin /exports C:\dll\3rdDLLName.dll" to see if it has a
properly exported function.

But from your description, it's more likely to be a COM library, which you
can directly "Add reference" if it contains the linking information, or
you can find the correct .tlb file for it.
(if it is the case, you'll see "DllRegisterServer" in one of the exported
functions)

"PenguinPig" <企鵝豬大爺@公司撰寫於郵件新聞:%2****************@ TK2MSFTNGP03.phx.gbl...
>Dear All

I have register a 3rd's DLL into my pc, and I can create an instance by
using CreateObject in ASP page, eg.
set obj = CreateObject("3rdDLLName");

And it contains several methods such as
string MyMethod(string)
string YourMethod(string)
string NoMethod(string)

Because of some reason, I need using this DLL's function in my C#
program,
so I do following
[DllImport("C:\\dll\\3rdDLLName.dll")]
public static extern string MyMethod(string content);

But when I call such method in my program, it throw
Unhandled Exception: System.EntryPointNotFoundException: Unable to find
an
entry
point named MyMethod in DLL C:\dll\3rdDLLName.dll

My question is
1. Do the method call in ASP is the EntryPorint of the Dll?
2. How to know the EntryPoint of the Dll?

Many Thanks



Jul 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: \(畔.睢lacK.毀珮) | last post by:
Hi! I want to move a node from file "film1" to "film2" that has tag "FilmatoPartita". I have write the codo below, but it don't do anything...I don't see the error... I have forgotten something?...
6
by: [Yosi] | last post by:
How can I make sure that a spicific function location in memory will not moved , by OS/Garbage collection ????? The problem is : I'm using a DLL this dll have an call backerror function, in my...
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
9
by: Moe Sizlak | last post by:
Hi There, I am trying to write the selected value of a listcontrol when a button is clicked and I keep getting the error "object not set to a reference of an object". The libox itself is in a...
1
by: Luis Esteban Valencia | last post by:
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source...
8
by: ginnisharma1 | last post by:
Hi All, I am very new to C language and I got really big assignment in my work.I am wondering if anyone can help me.........I need to port compiler from unix to windows and compiler is written...
10
by: Teja | last post by:
HI all, I have a problem in accesing COM objects in threads. To be precise, lets assume that I have a class GenericFunctions which is defined as follows: import win32com.client, pythoncom,...
5
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
14
by: ramadeviirrigireddy | last post by:
Hi All, I have the following code for form and servlet. when the form is submitted the servlet will print the values passed by the form. i'm not getting the servlet o/p when i submit the...
3
by: Ratan | last post by:
hi everybody, i want d code for d procedure to import data from excel sheet to db2 table. can anybody plz help me? its quite urgent. my mail id is ratan.nitrkl@gmail.com, yahoo chat id:...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.