Reputation: 21
I am trying to create an ICollection Interface pointer in Native C++ code using the below piece of code.
ICollectionPtr ptrPopItems (__uuidof(mscorlib::ICollection));
But I am getting a compliation error saying "Class not registered". Can someone help in solving this error?
Upvotes: 2
Views: 1063
Reputation: 89222
ICollection is not a COM object, which is what you would need for something like that to work. You need something like:
ICollection^ ptrPopItems = gcnew ArrayList();
ICollection is an interface, so you need to set it to an instance of a concrete class that implements its interace. The ^
is a pointer to a managed object and gcnew
calls the managed new
to create the object.
Take a look at this C++/CLI page on Wikipedia to learn more
http://en.wikipedia.org/wiki/C%2B%2B/CLI
EDIT: If you need to use C++ without the managed extensions, then you need to create classes in C# that do what you want and add the ComVisible
attribute to the classes you want to expose.
http://msdn.microsoft.com/en-us/library/7fcfby2t.aspx
Upvotes: 1