-
February 20th, 2014, 08:30 PM
#1
System::Object in C++
How do I create a System::Object in an unmanaged C++ project?
Thanks
and Canada rocks!! Peace bro.
-
February 20th, 2014, 08:42 PM
#2
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.
-
February 21st, 2014, 05:32 AM
#3
Re: System::Object in C++
Originally Posted by IndikaNiva
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
-
February 21st, 2014, 07:51 AM
#4
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).
-
February 21st, 2014, 11:04 AM
#5
Re: System::Object in C++
Originally Posted by OReubens
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 06: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.
-
February 22nd, 2014, 05:37 PM
#6
Re: System::Object in C++
Originally Posted by IndikaNiva
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|