thready
asked on
Using unmanaged C++ from C# with /clr
Hi Experts,
Just wondering if anyone has used the /clr option to convert unmanaged C++ to c#-ready code? Any problems? Any suggestions? I've got a big project written in MFC and would like to use lots of its libraries in a new Winforms project (Visual Studio 2008)
Thank you!
Mike
Just wondering if anyone has used the /clr option to convert unmanaged C++ to c#-ready code? Any problems? Any suggestions? I've got a big project written in MFC and would like to use lots of its libraries in a new Winforms project (Visual Studio 2008)
Thank you!
Mike
my experience was not good with unmanaged c++ and managed c++ both with c#
ASKER
Give me some details! :-) I'm all ears (well eyes), please...
i have seen lot many memory leaks (attempted to write to a memory location.., corrupted memory... write-protected location, etc.) other than that..i was almost lost on multidimensional arrays in c++.. this is just to name a few and more complicated.
HTH
HTH
I don't agree. If proper care is taken unmannaged code can be very efficient to use in a managed application. (Interop)
What I have generally done is taken a little bit of time to define how my data will move from unmannaged memory to managed memory. (Marshaling) Once this is well defined using native C++ libraries becomes relatively trivial.
As for using the /clr option to convert unmananaged code this does not make sense. Code in C++ is either written in managed or unmannaged form and generally is not well converted.
This sounds like a prime candidate for Interop.
Compile a native C++ (unmanaged) dll and use it with well defined Marshalling from your C# winforms app.
Good Luck!
MAC
What I have generally done is taken a little bit of time to define how my data will move from unmannaged memory to managed memory. (Marshaling) Once this is well defined using native C++ libraries becomes relatively trivial.
As for using the /clr option to convert unmananaged code this does not make sense. Code in C++ is either written in managed or unmannaged form and generally is not well converted.
This sounds like a prime candidate for Interop.
Compile a native C++ (unmanaged) dll and use it with well defined Marshalling from your C# winforms app.
Good Luck!
MAC
ASKER
Mac-will - this sounds pretty scary to me - marshaling.... There are a lot of libraries... I'm tempted to tell the customer that this will take some time - we only have 6 months to get this done. I'm probably better off sticking to MFC, rather than converting the project into .NET. Although this is something we want to build on, MFC should be around for a long time... Your thoughts on this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This answers my deeper question - many thanks Mac-will.
ASKER
Hi again Mac-will- the new MFC library you were talking about looks fantastic - and it is available to users of Visual Studio 2008 - do you know where to download it?
This version of MFC should be included with VS 2008. VS Express does not include MFC but all the other versions should have it.