Sign in to follow this  
alundgren

VC++ / C# Integration Help

Recommended Posts

Hello my minions, BACKGROUND I've been working on a game project for a while in vc++, so far have the graphics engine done. I've decided to switch to C# for game logic and networking, for speed of development. I want to keep the graphics unmanaged VC++ DX9, for performance. QUESTION I know you can reference unmanaged code (vc++) from managed (C#), and I want to do this with my graphics being in VC++ and my logic in C#. What are my options, what is recommended? I'd like to do this by making my graphics engine a DLL and referencing it from C#. Can this be done with the DLL exposing it's public interface as it normally would? I just need a quick overview of my options and how it would work, I can research the details myself. Also, any good links are appreciated. You may respond. __ Andrew

Share this post


Link to post
Share on other sites
COM can be quite complex but it has the advantage that you can at least work with interfaces (as you might know from DirectX). Using DLLs with DllImport will restrict you to functions only, no classes etc.

But I'd suggest a third alternative: write a thin .NET wrapper in C++/CLI. C++/CLI can make use of both managed and unmanaged code. The C# project can then use the DLL written C++/CLI as if it was any other .NET code - this is extremely convenient. SlimDX is a superb example of an adapter library written in C++/CLI. It provides access to DirectX to any .NET project.

Regards,
Andre

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this