calling a constructor with unmanaged arg by reflection

  • Thread starter Thread starter Ingo Nolden
  • Start date Start date
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
 
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
 
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?
 
Back
Top