M
muriwai
Hi,
VC++ 2008 /clr:
I have an unmanaged class: "class U" and managed one: "class ref M{ M(
const U* ); }". In other words, the constructor of the managed class M
takes the pointer to the unmanaged class U. I can call the constructor
directly no problem. I want to instantiate M via reflection.
Activator::CreateInstance() takes an array of parameters to be passed to the
constructor:
array< System::Object^ >^ pParams = gcnew array< System::Object^ >( 1 );
const U* pu = new U;
pParams[ 0 ] = pu;
The last line gives error C2440: '=' : cannot convert from 'const U *' to
'System::Object ^
My question is, how do I pass a pointer to an unmanaged class as a
constructor parameter to Activator::CreateInstance()?
Thank you,
Andrew
VC++ 2008 /clr:
I have an unmanaged class: "class U" and managed one: "class ref M{ M(
const U* ); }". In other words, the constructor of the managed class M
takes the pointer to the unmanaged class U. I can call the constructor
directly no problem. I want to instantiate M via reflection.
Activator::CreateInstance() takes an array of parameters to be passed to the
constructor:
array< System::Object^ >^ pParams = gcnew array< System::Object^ >( 1 );
const U* pu = new U;
pParams[ 0 ] = pu;
The last line gives error C2440: '=' : cannot convert from 'const U *' to
'System::Object ^
My question is, how do I pass a pointer to an unmanaged class as a
constructor parameter to Activator::CreateInstance()?
Thank you,
Andrew