473,387 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C# and DLLs

I'm trying to call unmanaged functions in a DLL from a C#
client program.
I've been over an over the tutorials and samples, but
still I'm missing something.
When one of these functions is called from the client
program, an unhandled exception is thrown stating that
there is no entry point in the dll by that name.
In the dll, I've qualified the function like this:

__declspec(dllexport) int iFunction(int);

In the client, I add this to a class

[DllImport("MyDll.dll")]
public static extern int iFunction(int iIn);

When I call the function, the dll is loaded, but the
iFunction name is not found.

Is there something else I need to do?
Thanks in advance.
Dennis
Nov 15 '05 #1
3 1189
Hi,

Take a look at the PInvoke tutorial in MSDN...

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/csref/html/vcwlkPlatformInvokeTutorial.asp

Regards,
Madhu

MVP | MCSD.NET
-----Original Message-----
I'm trying to call unmanaged functions in a DLL from a C#client program.
I've been over an over the tutorials and samples, but
still I'm missing something.
When one of these functions is called from the client
program, an unhandled exception is thrown stating that
there is no entry point in the dll by that name.
In the dll, I've qualified the function like this:

__declspec(dllexport) int iFunction(int);

In the client, I add this to a class

[DllImport("MyDll.dll")]
public static extern int iFunction(int iIn);

When I call the function, the dll is loaded, but the
iFunction name is not found.

Is there something else I need to do?
Thanks in advance.
Dennis
.

Nov 15 '05 #2
Is there something else I need to do?


Use a tool such as Dumpbin or Dependency Walker to find out the
exported name of the function, it's probably mangled.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #3
> __declspec(dllexport) int iFunction(int);

instead try:

#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif
EXPORT int iFunction(int);

Nov 15 '05 #4

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

Similar topics

2
by: Johann Blake | last post by:
I can hardly believe I'm the first one to report this, but having gone through the newsgroup, it appears that way. I would like to open a solution in the VS.NET IDE that consists of multiple...
2
by: Shiraz | last post by:
Hi I just made an installer for an application that uses two external COM dlls. On the surface, everything seems to be running smoothly and the the application runs without any errors. However,...
11
by: Devender Khari | last post by:
Hi Friends, I'm facing a situation as follows, need help on identifying possible issues. There is an MFC application developed in VC6.0, say ABCVC6.exe and another developed in VC.NET, say...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
7
by: Oenone | last post by:
I'm sure there's an obvious way to do this, but I'm missing it so far. I have an ASP.NET application that relies on several DLLs to work. Currently in order to get my site working I have to put...
6
by: Brian Bischof | last post by:
I'm having troubles getting the debugging process to work consistenly for external classes. I got it to work once and then I turned it off. But now I can't get re-enabled. Here is what I'm doing....
0
by: Dave | last post by:
Hello The application I'm building an installer for uses dlls which were developed originally in C. Since the application itself is developed in C#, these dlls were wrapped using SWIG....
7
by: Jeff Lynn | last post by:
Help! I recently upgraded my VS V6 to VS 2005 and was unable to build projects that were perfectly ok under VS V6. Where VS 2005 fails was in the linker resolving external DLLs, which are Open...
3
by: gopal | last post by:
I am developing an application in CSharp - windows forms based, which copies the DLLs both unmanaged and managed DLLs from a shared folder and will overwrite the existing versions of managed &...
10
by: =?Utf-8?B?UmljaGFyZA==?= | last post by:
Hi, I usually deploy my ASP .NET application to the server by publishing, using Visual Studio 2005 publish feature. This creates the Bin folder on the server, with the compiled DLLs. I've...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.