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

Using c++ unmanaged object methods in c#

Hi

I know how to call external c functions in c# through DllImport.
Now, i'm trying to call a c++ (unmanaged) class method, defined in an
external .dll as static int myClass::myMethod, and i wonder if it is
possible.
I have used the VS utility dumpbin /exports "myDllPath" in the
post-build event and have added the row extern "C"
__declspec(dllexport) int myMethod(int, int);
before the method implementation in the .cpp file, in order to set an
entry point (or so i believe...).
but it doesn't work, it raises the error "Unable to find an entry point
for <myMethodin DLL <myDLL>".
This make me think that it is not possible to use PInvoke (DllImport)
for c++ classes, even if the methods are statics, and the only solution
would be to wrap the unmanaged c++ class into a managed one.
Am i right?

thanks

Oct 25 '06 #1
1 1553

"Joneleth" <Jo*********@hotmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
| Hi
|
| I know how to call external c functions in c# through DllImport.
| Now, i'm trying to call a c++ (unmanaged) class method, defined in an
| external .dll as static int myClass::myMethod, and i wonder if it is
| possible.
| I have used the VS utility dumpbin /exports "myDllPath" in the
| post-build event and have added the row extern "C"
| __declspec(dllexport) int myMethod(int, int);
| before the method implementation in the .cpp file, in order to set an
| entry point (or so i believe...).
| but it doesn't work, it raises the error "Unable to find an entry point
| for <myMethodin DLL <myDLL>".
| This make me think that it is not possible to use PInvoke (DllImport)
| for c++ classes, even if the methods are statics, and the only solution
| would be to wrap the unmanaged c++ class into a managed one.
| Am i right?
|

Yes indeed you are.

Willy.
Oct 25 '06 #2

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

Similar topics

15
by: Brian Rogers | last post by:
Hello everyone, I apologize for the cross and re-post, but I am still searching for an answer. Why can C++ can create this object, but C# can't? I am trying to create an instance of the...
7
by: Willem van Rumpt | last post by:
Hi all, coming from an unmanaged programming background, I took my time to sort out the IDisposable and finalizer patterns. Just when I thought I had it all conceptually neatly arranged, the...
5
by: Chris Kiechel | last post by:
I am writing a .NET Windows application and it needs to perform DDE calls to a legacy system. I created a C++ unmanaged class that performs the actual DDE connection and communication. However,...
14
by: Jon | last post by:
Whether I can compile a class or not, depends on the order of functions in my class. My question is (see example below): 1) Is it a bug that the class 'WillCompile' will compile and execute, or...
5
by: Andrew | last post by:
I want to use a managed c++ class from an unmanaged class. Here is my code: // *** Unmanaged Code // .h file class UnmanagedClass { public: // Other stuff here
3
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object...
2
by: DocAccolade | last post by:
I am trying to include a legacy com control (controlname.ocx) in an asp.net application using vs 2003. I have added the control to the user control tool box, then dragged it to the form. However,...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
9
by: =?Utf-8?B?RWR3YXJkUw==?= | last post by:
I would greatly appreciate some help on passing managed object into unmanaged code. I need to pass a reference (address of) of a managed class into unmanaged code (written by a thrid party). The...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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: 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...

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.