I have a legacy C++ native code application that implements a class hierachy with some inheritance.
I have to re-implement the application within a managed framework.
TI would like to reuse the unmanged class hierarchy from the managed application and still benefit from the polymorphism built in to my unmanaged class hierarchy.
Do I have to write a C++/CLI wrapper for each unmanaged class in the hierarchy and duplicate the inheritance structure within the wrappers?
Assuming that you really do need to expose the full class hierarchy as managed types to managed code then yes, I think you're left duplicating the hierarchy with wrapper ref classes.
If the client managed application is also guaranteed to be C++/CLI (and not C#) it could #include the native class hierarchy intact and use it directly. If you want to allow C# then I'd use wrapper classes with the PIMPL idiom.
Also, hopefully your native classes don't use multiple inheritance since a managed class can only have one non-interface base class.
In my linker I get an error:
[bcc32 Error] Unit1.cpp(109): E2316 'GetScanline' is not a member of 'TBitmapData' Full parser context Unit1.cpp(42): parsing: void _fastcall TForm1::Button1Click(TObject *)
But I can clearly see it here Embarcadero API TBitmapData
Actually I have only 3 methods in TBitmapData - Pitch, GetPixel and PixelFormat. That is strange.
What should I do to use GetScanline?
I use Embarcadero RAD Studio XE3. And Firemonkey.
my application is in C++ and I need to call a method from application that is in C#
I use Visual Studio 2012 and I am completely new to this.
I tried some of the examples on this site but am frustrated by failure all the time.
I created a C++/CLR project
and used the example at following link, but can't get it to I don't know why it thinks I'm using unmanaged code while I checked the commandline options in my project and there is /clr in it. Is this related VS 2012? please help
With what? All you have done is tell us that you can't get it to work. You need to provide specific details of the failures and include extracts of the code that is giving the problem. If you are having a problem with the code of an article then you should use the forum at the end of that article to discuss with the author.
I would like to make a GUI, for sensor configuration purpose, with the style of MFC Application Wizard. Basically, I'd like
1. Multiple property sheets, each of which can interact with user inputs.
2. There is a browsing tree to list all the property sheets.
3. One can navigate through the property sheet by "Previous" and "Next" buttons; or, one may select a property sheet by clicking it in the browsing tree.
I program mainly in C++, and know well of VB. I wonder what tool and option would do the trick.
C# string becomes array<String^>^ in C++.
List<string> becomes List<String^>^.
Remember you need to allocate managed types with gcnew in C++. (The regular new is for unmanaged types.) The conversion is done automatically on function call. In fact it isn't even a real conversion, as the meaning/memory layout is the same, just the expression looks different. So you declare a function taking a array<String^>^ and pass in a string or the other way araound.
Keep in mind, you can't have C# and C++ in the same module (exe/dll) so you need to separate the code into different ones.
Freak30's answer is good and thinking about it I realize you may want to get the string value to native C++ code instead of just to C++/CLI. If that's the case, you'll want to look into the marshal_as templates.
I'll answer my own question for future visitors. Yes, adding the VERSIONINFO resource was necessary. And, it was easier than I thought - just right-click on Resource Files folder in Solution Explorer, Add > Resource... and select VERSIONINFO.