How to build an Hybrid Application using Visual C++ and .NET

On my Modeler application I want to code the feature of importing .NET types of any assembly to class development shape. To be successful, I need to use Reflection to enumerate types. So I begin to code that using C# as a stand alone assembly (dll):

Now, I have the data structure that contains all the assembly names for a dedicated assembly.

I will use my Modeler application to call this pseudo piece of code:

  • Open a File dialog box to select an assembly
  • Call the AssemblyExtractor assembly routines by passing the assembly name as a parameter
  • Get a List<ExtractorData> that contains the data
  • For each element, Add a development shape of class’s type and
  • Calculate a position on the screen for each element data

Here the C++ code that contains C++/CLI calls. In the same C++ file, i can call CLR routines because my project is configured to accept the CLR support.

My Modeler application is built using UNICODE. Strings are wide char alias wchar_t *. Here is the source code in the C++ file:


You can see I call the Extractor class in the C++ code !!! I manage String^ and List<T> datatypes. To enable this, I have added a reference of the AssemblyExtractor assembly to the project.

Here is the result:


Only C++ allows to mix C++ and C++/CLI .NET code. It is amazing…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: