combine c++ and c#

Hi everybody,
I wish to know, if it's possible to combine c++ and c#.
I mean, if I create a DirectX device using c++, could I draw it in a c# window.
I'm not so confortable with c# and I 'd like to develop a 3D modeler based on c++ with an c# interface (I suppose the easiest way to create fancy user interface).

Thanks for your help

[350 byte] By [VinceExtense] at [2007-12-25]
# 1

You can develelop you code in C++ and then expose it to C# as library using managed C++. Otherwise you can make you C++ code to be ActiveX control and use it from C# as such, yet another way is to make C++ dll with exported functions and then call the funtions from C# using dllimport attribute (just search the internet for examples and you will find thouthands of them).

MaksimLibenson at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 2
Ok , thanks a lot
but what is the greatest solution to keep speed advantage from c++ ? I guess, it's to make a c++ dll (last solutions ) ? Am I wrong ?
VinceExtense at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 3

My guess would be that the fastest solution (in terms of performance) will be to use managed C++ library (the first one). But managed C++ is very very complicated to use, it will be much more painfull than just to learn C#. Actually I think that you should not underestimate performace of C#, I think that in most cases it will not be easy to make faster code with C++ than C#.

Anyway here is an article on performace consideration when connecting native code and .NET:

http://msdn2.microsoft.com/en-us/library/ky8kkddw.aspx

MaksimLibenson at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 4
Ok Thanks a lot mate
VinceExtense at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...