473,385 Members | 1,930 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,385 software developers and data experts.

Unmanaged DLL

Ady
Hi

I am trying to call a function in C# that I wrote in unmanaged C++.

I am getting the following error.

An unhandled exception of type 'System.EntryPointNotFoundException' occurred
in TestApp2.exe

Additional information: Unable to find an entry point named DllMain in DLL
levelreader.DLL.

My C++ looks like this

#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

bool fileLoaded = false;
FILE * levelHandle;
extern "C" {
bool LevelOpen(char*fileName);
};
bool LevelOpen(char * fileName)
{
return FALSE;
}

and my c# looks like this

namespace TestApp2
{
public class Level
{
bool levelOpen;
[DllImport("levelreader.DLL",EntryPoint="DllMain")]
private static extern bool LevelOpen(string fileName);
public Level()
{
levelOpen = false;
}

public bool Open(string fileName)
{
levelOpen = LevelOpen ( fileName );
return ( levelOpen );
}
}
}
Any reason for this exception?

Thanks

Ady.
Nov 15 '05 #1
5 1678


"Ady" <ad**********@tcm.co.uk> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi

I am trying to call a function in C# that I wrote in unmanaged C++.

I am getting the following error.

An unhandled exception of type 'System.EntryPointNotFoundException' occurred
in TestApp2.exe

Additional information: Unable to find an entry point named DllMain in DLL
levelreader.DLL.


Remove the Entrypoint from the DllImport declarations. Please read the doc's
<ms-help://MS.MSDNQTR.2003JUL.1033/cpguide/html/cpconentrypointobjectfield.htm> carefully, Entrypoint refers to the function name
entry not DllMain.

Willy.
Nov 15 '05 #2
Ady
Hi,

I do not have this document is it on the MSDN website as I cant find it

Thanks

Ady.

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:e4**************@TK2MSFTNGP12.phx.gbl...


"Ady" <ad**********@tcm.co.uk> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi

I am trying to call a function in C# that I wrote in unmanaged C++.

I am getting the following error.

An unhandled exception of type 'System.EntryPointNotFoundException' occurred in TestApp2.exe

Additional information: Unable to find an entry point named DllMain in DLL levelreader.DLL.


Remove the Entrypoint from the DllImport declarations. Please read the

doc's <ms-help://MS.MSDNQTR.2003JUL.1033/cpguide/html/cpconentrypointobjectfield.h
tm> carefully, Entrypoint refers to the function name entry not DllMain.

Willy.

Nov 15 '05 #3
Ady
I have done what it says there but am still getting the exception anybody
help?

Thanks

Ady.

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Online MSDN library.

http://msdn.microsoft.com/library/de...bjectfield.asp

Nov 15 '05 #5
I have done what it says there but am still getting the exception anybody
help?


Try running Dumpbin.exe /exports on the DLL to see under what name the
function is actually exported.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #6

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

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
2
by: Paul Kenny | last post by:
Hi, I am trying to expose the functionality of an unmanaged C++ class to the other languages available in the .NET Framework. I have decided to do this by wrapping the unmanaged C++ class in a...
4
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
1
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the...
6
by: marek | last post by:
Hello All, we are doing a quite a big project that contains at the lowest level an unmenaged c++ classes. Above it there are managed wrappers and at the top there are ASP.NET pages. Can anyone...
6
by: Stephen Walch | last post by:
Our application environment consists of three basic layers: 1. Third-party unmanaged DLLs that were written before the CLR was invented and maintain a significant amount of information (including...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
5
by: akash | last post by:
I'm having problems calling an unmanaged class from a managed wrapper. I suspect I'm missing something obvious, as I'm unfamiliar with C++ and classes are very simple. My unmanaged class is as...
2
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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...

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.