calling a constructor with unmanaged arg by reflection

I

Ingo Nolden

Hi,

I want to call the constructor of a managed class by reflection.

This is not problem so far. I have the instance of ConstructorInfo, that
belongs to the constructor I want to call. But the Argument is an
unmanaged pointer. ConstructorInfo::Invoke however accepts only an array
of managed objects.
If the Arg were a ValueType I could easily __box it, but what can I do
with a pointer to an unmanaged type?

thanks
Ingo
 
M

Mattias Sjögren

Ingo,
If the Arg were a ValueType I could easily __box it, but what can I do
with a pointer to an unmanaged type?

System::Reflection::pointer::Box()



Mattias
 
I

Ingo Nolden

Mattias said:
Ingo,




System::Reflection::pointer::Box()



Mattias
Thank you,

I just tried that. It works very well. It's such a freaky technology.
The thing that surprises me is, that creating an object by reflection
and getting the type by string name is not significantly more time
consuming than to program a direct constructor call for each type.


Does .net use heavily string pooling to find the types so quickly?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top