index > Visual C# General > Defining a DLL entry point in C#? (DLLEXPORT not DLLIMPORT)

Defining a DLL entry point in C#? (DLLEXPORT not DLLIMPORT)

I want to call a DLL class library written in C# from unmanaged C++. I saw this example: http://msdn2.microsoft.com/en-us/library/2x8kf7zx.aspx. It works so I tried to transfer it to my files. I got a System.EntryPointNotFoundException. The problem is: How do you define an entry point in a C# DLL? The C++ seems to work so the error must be in the C# DLL.
lagu26537

hi there,

The error that you are getting means that either the function name is in-correct or the parameters that are provided by you are not proper.

Please check the name of the function and its parameters as well its datatypes.

Secondly initially in the Classic VB 6.0 \ VC++ days there use to be a tool called as API viewer using which you can view the function's name and its parameter. Try to get that tool or you can also visit the http://www.pinvoke.net site to check out the details of the unmanaged API.

Regards,

Nasha {MVP}.

If you find this post useful please mark it on the forum.




B +ve thatz my attitude
Nasha

The DLL is not unmanaged. It is managed. I have source code for both projects the .exe and the .dll. I wrote both of them today. It is the .exe-file which is unmanaged (Win32 Console application (C++). It has to be unmanaged because that's the situation in the real project.). The DLL is a C# class library. What C# lines of code do you put in the DLL C# class library in order to create an entry point?

I checked with $ dumpbin.exe -exports CSTaxCalc.dll It returned:
----------------------------------------------------------
$ dumpbin -exports CSTaxCalc.dll
Microsoft (R) COFF/PE Dumper Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file CSTaxCalc.dll

File Type: DLL

  Summary

        2000 .reloc
        2000 .rsrc
       
2000 .text
----------------------------------------------------------
So there are no entry points in the DLL-file. Don't you have to put in lines of code to get entry points into the DLL? Like e.g.

----------------------------------------------------------
extern "C" __declspec(dllexport) __cdecl
                          int summis(int a,int b);

----------------------------------------------------------

Thanks, Lars

lagu26537
i have this problem too..

And i`m made my dll in c# , and when i tryed to use DLLIMPORT same exception occured.. i know that my dll is a valid COM but what if i want to use the DLLIMPORT ???



#include "Univers.h"
zapacila89

C# doesn't support this.




Mattias, C# MVP
Mattias Sjögren
There's an example in chapter 21 of Sam's teach yourself Visual C++ .NET (2002) that does just this. The problem is that the recepy they describe doesn't work in VS 2005. If you import the solution to VS 2005 you get compiling errors.
lagu2653
reply 6

You can use google to search for other answers

 

More Articles

• Add Node existing XML file
• Regarding MCPD
• using dataGridView EditingControlShowing for Keypress and multip...
• C# Forms help for newb.
• Why did I only get part of what I intend to get?
• How do I open a second form????
• App.Config for Entire Solution
• How to Open C# Program with Parameter from Command Line ?
• embedded resource HTML
• Nested Generic Approach
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Bugs in the Shareware Starter kit
• How can I change the highlight backgroun
• Picture + Text in One richTextBox
• exporting millions of records
• IIS Web Control Panel
• Console window keeps closing itself
• a question on multithreading
• Automatically do something after X amoun
• Server timeout when UseDefaultCredential
• Unable to open FORM2
• Calling Win32 API Functions from .NET
• Do I need to implement Dispose() if my C
• Application.Exit() not working
• Unable to open the physical file"
• Region.IsVisible - relative or absolute

Hot Articles

• Voice Chat in C#
• Achieving full CPU usage for large tasks
• need to encrypt dataset output PRIOR to
• The event handler Keypress doesn't start
• C# Windows environment book
• Running programs from a windows service
• Reflection
• WM_SIZE problem
• How Can I Create File or Folder on [Map
• help with wireless communication
• Help in regular expression
• How to run an axecutable application fro
• Reuse code
• Word component in Visual C#
• sending and recieving mail in c#

Recommend Articles

• double buffering to fix flickering ToolS
• TreeNode Tag problem
• Form2Form Problem in Visual c# Express
• vs 2005 c# and infopath!
• To move from one textbox field to another
• debug vs release
• Line spacing
• Images in DataGrid problem...
• Help. I want to edit registry
• DataGridView ComboBoxColumn Selection
• Custom property
• Search For Files?
• How to Convert HtmlData to string *** Ur
• ListView with CheckBoxes checks unwanted
• OTP help with run