Jump to content
  • Advertisement
Sign in to follow this  
Richard3d

C# inside of c++, calling all .NET gurus

This topic is 3543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I know the opposite is definitely possible however is it possible to use a c# dll or .NET module inside of a c++ project. I want to call methods and such from the DLL inside of my c++ app. Any information on how to accomplish this would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Yes, it's possible to call functions in .NET modules from C++. The easiest way is to compile the C++ project as a CLR project and include the reference(s) to the .NET module(s). Another choice is to expose your .NET modules to COM and use standard COM programming techniques to access classes defined in .NET.

Share this post


Link to post
Share on other sites
Thank you very much for the fast response. I have just a few more questions regarding the reply.

1) I have seen the CLR project option in MSVS before but is it possible to do this from say a win32 console app or other type of project as well? i.e. what are the configuration differences between a CLR app and others?

2) You mentioned I could access classes and such using COM techniques. Are you implying that only methods and not classes or structs may be accessed with the referencing include in a CLR app?

3) What are some good web resources with info on this stuff. I had a lot of trouble finding info on doing this, going the other way was easy (using c++ in c#)

Thanks in advance!

Share this post


Link to post
Share on other sites
1) An existing C++ project can be changed to use the CLR by going to Project Properties/General/Common Language Runtime support and changing the option to one of the /clr options. (At least in 2008. I'm pretty sure it's the same in 2005.)

2) Classes implementing COM interfaces can be accessed via COM and you can invoke exposed methods and access properties.

3) I already linked you to the documentation on MSDN for exposing a .NET class to COM. For using .NET objects from C++/CLI you should consult a language reference for C++/CLI.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!