Managed C++ question regarding structs

OneOfTheseDays

Diamond Member
Jan 15, 2000
7,052
0
0
I have a struct declared in some C# code. This struct has it's own constructor to setup the various fields in the struct. I want to be able to call this constructor in Managed C++ code, but I keep getting the following error msg "Operator New allocates value types on the C++ heap, use '__nogc". When I use __nogc I get the following error msg "Cannot dynamically allocate this value type object on the native heap".

What can I do here guys? I can't set the fields manually either because I don't have direct access to them. You can only setup the fields via the constructor. Thanks.
 

sao123

Lifer
May 27, 2002
12,653
205
106
Originally posted by: OneOfTheseDays
I have a struct declared in some C# code. This struct has it's own constructor to setup the various fields in the struct. I want to be able to call this constructor in Managed C++ code, but I keep getting the following error msg "Operator New allocates value types on the C++ heap, use '__nogc". When I use __nogc I get the following error msg "Cannot dynamically allocate this value type object on the native heap".

What can I do here guys? I can't set the fields manually either because I don't have direct access to them. You can only setup the fields via the constructor. Thanks.

post some code plz... but it sounds like you are trying to allocate a managed type on unmanaged memory... you may have to use the use the unmanaged default types...