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

call c# dll function from another app

What I'm trying to do is invoke a c# dll from a c++ application. I
don't know whether my problem is in the c# or the c++ code.

My c# dll contains a public static function that I'm trying to invoke.
However, I can't obtain a pointer to the function. Using
AfxLoadLibrary from the c++ side, the library loads fine, but
GetProcAddress returns null.

I've been searching through documentation, but came up empty. What am
I missing?

Feb 2 '06 #1
4 1701
dotnetchic,

.NET dlls can not be accessed in this manner, since they do not export
functions that can be found using GetProcAddress.

Rather, you have to expose your object as a COM object in order to use
it in unmanaged code, or use managed C++ to access it (the latter being the
easier, in my opinion).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"dotnetchic" <do********@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
What I'm trying to do is invoke a c# dll from a c++ application. I
don't know whether my problem is in the c# or the c++ code.

My c# dll contains a public static function that I'm trying to invoke.
However, I can't obtain a pointer to the function. Using
AfxLoadLibrary from the c++ side, the library loads fine, but
GetProcAddress returns null.

I've been searching through documentation, but came up empty. What am
I missing?

Feb 2 '06 #2

"dotnetchic" <do********@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
| What I'm trying to do is invoke a c# dll from a c++ application. I
| don't know whether my problem is in the c# or the c++ code.
|
| My c# dll contains a public static function that I'm trying to invoke.
| However, I can't obtain a pointer to the function. Using
| AfxLoadLibrary from the c++ side, the library loads fine, but
| GetProcAddress returns null.
|
| I've been searching through documentation, but came up empty. What am
| I missing?
|

C# (or managed assemblies) cannot be loaded by LoadLibrary and family, what
you can do is build a wrapper library in C++ (mixed mode) that wraps the C#
classes and thunks the calls from C++. Yet another option is to use COM
interop to create and access your C# classes.
Check this: http://msdn2.microsoft.com/en-us/library/ms177552.aspx for "C++
interop", I would also suggest you to post your questions to a vc NG or one
the vc forums at http://forums.microsoft.com.
Willy.

Feb 2 '06 #3
Here is an example which uses COM Interop to expose a .NET assembly to
COM clients. This particular example exposes the DLL to a Java client,
but the COM Interop steps for generating the COM callable wrapper are
the same for any COM client.

http://j-integra.intrinsyc.com/suppo...?article=78813

Regards,
Shane Sauer
------------------------------------------------------------------------------
J-Integra Interoperability Solutions
http://j-integra.intrinsyc.com/
high performance interop middleware for java, corba, com & .net

Feb 2 '06 #4
Thanks. I may try that route. I was hoping to opt for the easy way
out, though...

Feb 3 '06 #5

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

Similar topics

4
by: mangi03 | last post by:
Hi, I came acrosss g++ compile errors whenever I make a function call by reference and found out from the test program that compiler is treating the function argument differently when another...
3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
2
by: FAN | last post by:
I want to define some function in python script dynamicly and call them later, but I get some problem. I have tried the following: ################################## # code...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
5
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
5
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in...
6
by: mygoogleaccount | last post by:
Hi, may be someone could help me ? i need to use cyrillic letters in a php application. I changed everything to UTF-8 and it works fine. The only problem are CYRILLIC SMALL LETTER ES...
46
by: Steven T. Hatton | last post by:
I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it says. http://java.sun.com/docs/books/tutorial/essential/concurrency/syncrgb.html <shrug> -- NOUN:1. Money or...
11
by: Felix Kater | last post by:
Hi, I can compile and run this code (see below) which twice calls the function f, first with too less, second with too much arguments. But is it legal and free of memory leaks and other...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.