Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Intro to Managed C++, Part 2: Mixing Managed and Unmanaged Code
Subject:   Why C#?
Date:   2003-03-05 14:34:52
From:   anonymous2
In your article you suggest more than once the idea of porting to C#. Why? Why not just leave everything in managed/unmanaged C++, or even just managed C++? What is with the emphasis on C# everywhere?
Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Why C#?
    2003-03-07 12:56:51  samgentile [View]

    Good question. The issue is accessibilty from managed code. I have no problem leaving everything in MC++ but there are hordes of .NET programmers who inist on C# or VB and believe it or not call C++ and MC++ "dead" languages in the face of the CLR-) There may be "consumers" of said MC++ code that want to access that code from C# or VB.NET so I show how to do it.

    Also, previous to Everett, there was no forms designer in VS.NET so it made sense to "port" the C++ code to managed and then use C# to quickly write up the UI because of its WinForms Visual Designer and then call from it to the MC++ code.

    Its not me thats pushing C#. Its Microsoft.
    • Why C#?
      2008-02-03 06:41:10  ailyag [View]

      Hello everybody!
      I've got the concept you discuss.
      But I have difficulties with using C++ managed DLL in C#.
      There is no problem call just a funtion from DLL by declaring as follows:
      [DllImport("CFS01.dll", CallingConvention = CallingConvention.Cdecl)]
      private static extern MyClass unmanagedMethod(float x, float y);


      But I have difficulties in working with the instance of managed class in C#. I cann't call the member functions of class without declaring its body.

      In my DLL I have managed class which wraps the unmanaged one and operates with it.

      How should I adapt my managed class for my application?
      How should I make visible my managed class with all its member functions without declaring?

      Can you show a simple example of similar situation solved?
      I guess that it may be the configuration problem.

      Thank you for help!