Skip to content

Managed C++/CLI

Discussions on Managed Extensions for Visual C++ .NET

This category can be followed from the open social web via the handle managed-c-cli@forum.codeproject.com

4.4k Topics 14.9k Posts
  • What's the difference between VC++ and Managed C++?

    c++ com question
    3
    0 Votes
    3 Posts
    2 Views
    N
    Managed c++ - the C++ code will be run under the CLR. you can take advantage of the CLR services and be aware of its limitation (for example the CLR control the memory allocation) COM - is a protocol used by Microsoft in the latest years (until the appearance of .Net) to enable communication, transfer of data and activation of components (DLL, EXE, OCX …) writing in different development tools and languages. As long as the provider and consumer support COM a communication can established between them. ATL (Active Template Library) - is a library that enable c++ programmer to write components that support COM with less effort. The ATL contain templates that encapsulate many coding issue regarding to COM and let you spend more time on your application rather on COM.
  • Covariant return types

    csharp c++ database visual-studio help
    8
    0 Votes
    8 Posts
    11 Views
    D
    Paul Selormey wrote: I do not think it is an issue of time since it took four years of development from VC++ 6.0 release. With very little improvement in MFC, and some web-stuff updates for ATL four years was enough to do effective work. Or maybe they could only start their work after most parts of .NET framework were done. It's not the fall that kills you: it's the sudden stop - Down by Law, Jim Jamursch (1986)
  • Unmanaged code to call managed code

    c++ graphics docker data-structures
    2
    0 Votes
    2 Posts
    2 Views
    P
    System::Array will not provide the STL vector style container. Consider System::Collection::ArrayList. You can derive from the ArrayList and add new methods which match the STL::vector to make the porting easier. If you still have problems, then post some codes. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
  • C2682: cannot use __try_cast to convert from 'gcroot<T>'

    question c++ graphics help
    2
    0 Votes
    2 Posts
    2 Views
    P
    Got this response from one Jochen Kalmbach, and it works :) Normaly you should do: System::Drawing::Brush *b; b = m_pDotNetBrush; Then you can try to cast it... System::Drawing::SolidBrush *pBrush = __try_cast < System::Drawing::SolidBrush* > (b); -- Greetings Jochen Jesus Christ is LOVE! Please tell somebody.
  • Mixing ATL and MC++

    c++ csharp hosting help question
    2
    0 Votes
    2 Posts
    0 Views
    P
    Hello Heath, Welcome to MC++. I think you should start by reading the MC++ reference document. It is small and straight. Download the word format and print it if you wish to work with the MC++. Now, to your question. You cannot derive __gc class from __nogc class or vice versa. You can have each as members (wrapper stuff). For controls you can subclass and superclass where necessary. In my recent project, we had MFC ActiveX GIS control and wanted to port it to .NET. I quickly reworked the rendering in ATL/WTL and with MC++ got it working. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
  • Socket function error

    help com question
    2
    0 Votes
    2 Posts
    0 Views
    P
    Hello Aaron, Please try the Visual C++ forum for API/VC++/MFC questions. This forum is for MC++. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
  • Form within Form ...

    question c++ graphics
    2
    0 Votes
    2 Posts
    0 Views
    P
    For your needs, I think UserControl will do. However, it is possible to place a form in a form. This key is setting the TopLevel property to false before adding and making sure it is visible. It will even appear in the Designer, just that the TopLevel part will be deleted in the designer. The following is a complete source which will compile to display a form in a form, try it... #pragma once namespace MustGo2 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// public \_\_gc class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } protected: void Dispose(Boolean disposing) { if (disposing && components) { components->Dispose(); } \_\_super::Dispose(disposing); } private: System::Windows::Forms::Form\* panel1; private: /// /// Required designer variable. /// System::ComponentModel::Container \* components; /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// void InitializeComponent(void) { this->panel1 = new System::Windows::Forms::Form(); this->panel1->TopLevel = false; this->SuspendLayout(); // // panel1 // this->panel1->AutoScaleBaseSize = System::Drawing::Size(5, 12); this->panel1->ClientSize = System::Drawing::Size(248, 198); this->panel1->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D; this->panel1->Location = System::Drawing::Point(16, 16); this->panel1->Name = S"panel1"; this->panel1->Visible = true; // // Form1 // this->AutoScaleBaseSize = System::Drawing::Size(5, 12); this->ClientSize = System::Drawing::Size(292, 266); this->Controls->Add(this->panel1); this->Name = S"Form1"; this->Text = S"Form1"; this->ResumeLayout(false); } }; }
  • Managed and Unmanaged

    csharp c++ design tutorial
    8
    0 Votes
    8 Posts
    0 Views
    K
    Thanks Sam, nice to see you hear in CP :-) I've been reading your blogs for quite some time. I hope to see more articles from you on MC++ and COM/Interop. regards Kannan
  • Predefined bitmaps for toolbars ?

    c++ csharp question
    4
    0 Votes
    4 Posts
    0 Views
    H
    It was an option while you were setting up Visual Studio. You may want to change your setup options from Add/Remove Programs for Visual Studio and have them installed. They come in handy. Another way is to use ildasm.exe to dump the IL and resources (everything in the assembly referenced in the assembly manifest) into a directory for the major assemblies like System.dll, System.Design.dll, System.Drawing.dll, and System.Windows.Forms.dll. There's a lot of goodies in there! Reminiscent of my younger years... 10 LOAD "SCISSORS" 20 RUN
  • resx-files in VC++.net 2002

    csharp question c++
    3
    0 Votes
    3 Posts
    5 Views
    V
    Hi Paul! I solved my problems and (as you said) use the command line tools. 1. I add the resource files (resx and txt for strings) and the localized versions to the project. 2. For the neutral resource, I set resgen $(InputFileName) $(InputName).resources as the commandline and "$(InputName).resources" as the output file 3. For all localized resources I set the command line to e.g. resgen $(InputFileName) $(InputName).resources al /v:1.0.* /target:lib /embed:$(InputName).resources /culture:de /out:$(OutDir)/de/$(TargetName).resources.dll and $(OutDir)/de/$(TargetName).resources.dll as the output file to create the satelite assemblies. 4. In the project settings Linker->Input->Embed managed resource file I add strings.resource That's it, works sweetly for me, although it is not as easy as it could be. Why does MS stick to .rc/.res in VC++.net 2002? - Andre
  • How is an application's window turned into icon?

    c++ question
    4
    0 Votes
    4 Posts
    0 Views
    P
    Can't remember :laugh::laugh::laugh: Anyway, we are trying to make sure any MC++ programmer here is satisfied and we cannot include non-MC++ stuff ;P Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
  • C# DLL in VC++

    c++ question csharp dotnet help
    4
    0 Votes
    4 Posts
    0 Views
    P
    Then you can only use it as an "ActiveX" control, through the COM Callable Wrapper - CCW. There is MFC sample in the MSDN demonstrating using the WinForm as MFC View. You can also read this MSDNMag artcle, which has a sample putting .NET control in MFC dialog. You can use the Type Library Exporter tool (tlbexp.exe) to generate the type libraries or the other tools and classes provided by the .NET Framework. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
  • Managed C++ starting unmanaged threads?

    c++ design hardware question
    6
    0 Votes
    6 Posts
    0 Views
    P
    :laugh::laugh::laugh: I stand by my review and will write a new book for you if this does not make the grade ;P Anyway, welcome to the .NET Remoting - be prepared to answer my questions on the forum on .NET Remoting since I will be starting a project on this next 2 weeks. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
  • ANSI compliant XML Parser?

    xml csharp c++ html linux
    4
    0 Votes
    4 Posts
    0 Views
    P
    You have everything having to do with C++ there, but with .NET here - that is the difference. ;P Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
  • Creating objects on stack

    csharp c++ dotnet data-structures
    8
    0 Votes
    8 Posts
    0 Views
    V
    Whoops, it seems I did not get an e-mail notification. Something's going on in here, I see. I'm short on time right now, so I cannot post the test code (maybe it was a test way too naiv at all). I'll post it when I have a little more time. Thanks already for the interesting research, Jeff! - Andre
  • Save increment filename ...

    help
    2
    0 Votes
    2 Posts
    0 Views
    P
    Please this is MC++ forum, try the Visual C++ forum for MFC stuff. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
  • Mixins and __gc

    question c++ wpf help
    3
    0 Votes
    3 Posts
    0 Views
    J
    Thank you very much! -=jarl=- Laird Of Glenmore
  • 0 Votes
    3 Posts
    0 Views
    C
    OOPS! Go figure I'd mess up:~ ... sorry!
  • Managed/Unmanaged: pinning ptr madness

    question c++ performance csharp help
    5
    0 Votes
    5 Posts
    0 Views
    J
    Hi VizOne, Sorry for the late reply. VizOne wrote: But what about __value object? They are stored on stack, aren't they? Will stack object be move during collection, too? Although __value objects are typically stored on the stack, they can also be put on the heap. Stack objects are the same in .Net as they are in regular C/C++, so they won't move. How heavy would you say is pinning a pointer? Is it a real performance issue if I keep the pointer pinned only for some native calculations that won't last more then a view microseconds? I did some preliminary tests too, and I could barely measure any performance differences. I forced GC collections during them. The GC does not collect very often under normal circumstances, so I don't see pinning as costly either. Your tests jibe with mine. Of course reinterpret_cast is an evil monster, but I have to use it here, haven't I? I always do, and MC++ code that ships with .Net uses it too. I really think MS is just playing it "safe". As I recall, reinterpret_cast was just discouraged. The software world would grind to a halt if such casts were never used ;) The reinterpret_cast is safe and ok, or not? I usually call native functions from MC++ much like you do. As long as managed objects are pinned and the cast is appropriate, safety should not be of concern. Cheers
  • Managed and Unmanaged structures

    help c++ question lounge
    6
    0 Votes
    6 Posts
    0 Views
    J
    ...ah....I see...;P -=jarl=-