473,326 Members | 2,588 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,326 software developers and data experts.

Getting An unhandled exception of type 'System.EntryPointNotFoundException'

Hi ,

I am trying to call a method from unmanaged DLL in my C# client application.
I am getting this exception "An unhandled exception of type 'System.EntryPointNotFoundException' occurred in DLLInjection.exe"

My C# Client code:
Expand|Select|Wrap|Line Numbers
  1. public class ImportedFunction
  2.     {
  3.        [DllImport("C:\\CPP Project\\DLLInjection\\Debug\\Win32DLL.dll")]
  4.        public static extern int GetStorageName();
  5.  
  6.     }
  7.  
In Main()
Expand|Select|Wrap|Line Numbers
  1. Console.Write("Calling Imported Function...");
  2.  
  3.             int k=ImportedFunction.GetStorageName();
  4.  
  5.  
IN C++ file.
Expand|Select|Wrap|Line Numbers
  1. #define DllExport   __declspec( dllexport)
  2.  
  3.  
  4. extern "C" DllExport int __stdcall
  5.  GetStorageName();
  6.  
  7. // dllmain.cpp : Defines the entry point for the DLL application.
  8. #include "stdafx.h"
  9. #include "dllmain.h"
  10. #include<Windows.h>
  11.  
  12. BOOL APIENTRY DllMain( HMODULE hModule,
  13.                        DWORD  ul_reason_for_call,
  14.                        LPVOID lpReserved
  15.                      )
  16. {
  17.     switch (ul_reason_for_call)
  18.     {
  19.     case DLL_PROCESS_ATTACH:
  20.     case DLL_THREAD_ATTACH:
  21.     case DLL_THREAD_DETACH:
  22.     case DLL_PROCESS_DETACH:
  23.         break;
  24.     }
  25.     return TRUE;
  26. }
  27.  
  28.  
  29. int __stdcall GetStorageName()
  30. {
  31.     return 100;
  32. }
  33.  
Please help
Aug 28 '11 #1
4 4880
Is it actually doing the import?
Aug 28 '11 #2
Yes ...I m trying to import the function from DLL(written in C++)
Aug 28 '11 #3
Bit of a misunderstanding.

You're trying to import a DLL. Have you checked that the import is actually happening? (by the looks of it, the binary cannot find the imported dll)
Aug 28 '11 #4
bvrwoo
16
Does your dll have a .def file? Linking the DLL (plus .H and .LIB) in a C++ project does not need .def if using __declspec(dllexport) before the function, but it does with C#/VB.NET.
Aug 29 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rafael | last post by:
Hi, I hope I can find some help for this problem IDE: Visual Studio.NET 2003 Developer Editio Language: C# Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
1
by: Lee Holsenbeck | last post by:
Hi, I get this error in a vb.net windows application in the .exe: "An unhandled exception of type 'System.argumentException' occurred in system.drawing.dll" This occurs only on 1 user's pc,...
1
by: Merlynx | last post by:
i am getting that error with the Event() method. Don't know whether if i have used the CreateEvent function well as it is the 1st time i used it moreover i am net to C#. If anyone can point me out...
4
by: Anders Borum | last post by:
Hello! I am working on improving my threading skills and came across a question. When working with the ReaderWriterLock class, I am getting an unhandled exception if I acquire a WriterLock with...
1
by: SMG - Idealake | last post by:
Hi all, I am getting following error on my error, what could be the reason? Exception of type System.OutOfMemoryException was thrown. Description: An unhandled exception occurred during the...
0
by: ibiden ibiden | last post by:
Hi, I'm trying to use a COM DLL (done with VB6) from .NEt and i get the folowing exception type : System.Runtime.InteropServices.COMException The DLL is well registred and referenced in my...
3
by: Ankit Aneja | last post by:
This is my problem. I am using Visual 2003, .Net framework 1.1 and the Application Block I configured the DAAB using the Enterprise Library Configuration now this is the error which is coming ...
0
by: cybersurfer | last post by:
Hi All I am using the Kodak Suite of Imaging controls (OCX) to make a basic image viewing and editing application. But, when using the ImageThumbnail control I get an unhandled exception in...
1
by: =?Utf-8?B?Wmlub24=?= | last post by:
Hello I have an ASP.NET 2 intranet application written in C#. I use Active Directory authentication and parts of the application uses AJAX. From time to time (about once every 200-300 accesses...
7
by: j4richard | last post by:
Help please, I am getting this "Unhandled Exception has occurred in your application" " A Generic error occurred in GDI+" See the end of this message for details on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.