I have an unmanaged code that has the following definition,
void Load(const somestruct& structinst)
{
//dosomething.
}
I want to pass a structure from CLI to this method in the unmanaged code as a ref and get back the structure in CLI.
I tried creating a struct in CLI as
[StructLayout(LayoutKind::Sequential, CharSet = CharSet::Ansi, Pack = 2)]
ref struct TEST
{
[MarshalAs(UnmanagedType::SysInt)]
int k;
};
and tried passing the struct as
CLIWrapperClass::WrapperMethod()
{
TEST test;
this->NativeClassInstance->Load(test);
}
and am getting an error like error C2664: 'NativeClass::Load' : cannot convert parameter 1 from 'Namespace::WrapperClass::TEST' to 'NativeClass::somestruct&'
How would I achieve this?