• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Managed C++ question regarding structs

OneOfTheseDays

Diamond Member
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.
 
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...
 
Back
Top