System::Object in C++
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: System::Object in C++

  1. #1
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,889

    System::Object in C++

    How do I create a System::Object in an unmanaged C++ project?

    Thanks
    and Canada rocks!! Peace bro.

  2. #2
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,889

    Re: System::Object in C++

    Also if anyone have sample code to call Excel (any office app) Dialog->Show() method using IDispath interface. using GetIDFromName and Invoke(), calls, that would be so thankful.

    I can post my code if someone is willing to look,
    I can get the ID from name but the Show() takes 30 parameters!!! I have tried VARIANTS etc etc, it throws Invalid Args exception
    and Canada rocks!! Peace bro.

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,467

    Re: System::Object in C++

    Quote Originally Posted by IndikaNiva View Post
    How do I create a System::Object in an unmanaged C++ project?

    Thanks
    FYI: "unmanaged C++" is officially called "native C++"
    Why do you need a System::Object in a Visual C++ project?
    Victor Nijegorodov

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,968

    Re: System::Object in C++

    The short answer is "you can't".

    You can have a hybrid project with native c++ as a base and c++/cli support in selected sources.

    You can also have a native C++ project that uses .NET through COM interfaces, but you'll have to provide those COM interfaces (and write the C++ code to use COM).

  5. #5
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,591

    Re: System::Object in C++

    Quote Originally Posted by OReubens View Post
    The short answer is "you can't".
    Yep!

    You can also have a native C++ project that uses .NET through COM interfaces, but you'll have to provide those COM interfaces (and write the C++ code to use COM).
    That's the closest you can get to handling managed objects in a pure native app, in case you have an out-of-process COM wrapper around the managed classes involved. Your app wouldn't depend on the .NET framework then, yet the COM wrapper would.

    What you can have is a reference to a managed object in a native class. See the auto_gcroot<T> and gcroot<T> class templates and sample code here: http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx. I don't know whether that really can help you, though, since I don't have a clear idea of what you intend to do with the managed object(s). And an app using these would be hybrid native/managed, not purely native.

    On the side note, why would you want to create a System::Object? A raw System::Object (as opposed to one representing an instance of a derived class) is hardly ever of any practical use.
    Last edited by Eri523; February 22nd, 2014 at 05:03 PM.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  6. #6
    Join Date
    Jul 2013
    Posts
    301

    Re: System::Object in C++

    Quote Originally Posted by IndikaNiva View Post
    How do I create a System::Object in an unmanaged C++ project?
    You use C++/CLI.

    It was specifically designed to handle these kinds of question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center