Unmanaged DLL calling a C# class 
Author Message
 Unmanaged DLL calling a C# class

I have a VC++ unmanaged DLL, and I'd like to call some methods in a C#
assembly. Is there any magic juju that will allow me to simply add a
reference and call it, or do I need COM interop?


Tue, 15 Feb 2005 09:15:41 GMT  
 Unmanaged DLL calling a C# class
Use tlbexp and regasm :-)

Nish


Quote:
> I have a VC++ unmanaged DLL, and I'd like to call some methods in a C#
> assembly. Is there any magic juju that will allow me to simply add a
> reference and call it, or do I need COM interop?



Tue, 15 Feb 2005 12:05:30 GMT  
 Unmanaged DLL calling a C# class

Quote:
> I have a VC++ unmanaged DLL, and I'd like to call some methods in a C#
> assembly. Is there any magic juju that will allow me to simply add a
> reference and call it, or do I need COM interop?

These rules might help you call C# from C++ code (even MFC code !):

1. "#undef new" in the C++ code before the "#pragma managed"
2. Turn on the managed extensions option in the VS.NET project
    for an MFC app
3. The C# dll MUST be in the same directory as the C++ MFC exe

You might need some #using statements in your C++ code like this:

#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
#using <cs_dll.dll>

#pragma managed

Lynn



Tue, 15 Feb 2005 21:18:57 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Call C# dll from unmanaged C++

2. Unmanaged C++ calling managed C# dll

3. Problem calling into managed DLL that calls unmanaged DLL

4. C# client crashs when calling into Managed C++ which calls unmanaged c++ function

5. Calling a Managed DLL from and UnManaged DLL

6. call a C# class from a VB 6 COM dll

7. Unmanaged C++ calling GUI in C#

8. example of unmanaged C++ calling C# ?

9. Calling unmanaged code from ASP.NET (C#)

10. Calling unmanaged member functions from C# (again)

11. C# classes and unmanaged c++

12. using C# enum in C++ unmanaged class

 

 
Powered by phpBB® Forum Software