D
DaTurk
I'm having an issue converting an unmanaged struct to a CLI managed
struct. It's a value struct and this cannot be changed.
[StructLayout(LayoutKind::Sequential, CharSet=CharSet::Ansi, Pack=1)]
public value struct UpdateItem
{
public:
[MarshalAs(UnmanagedType::ByValTStr, SizeConst=50)]
System::String ^Name;
[MarshalAs(UnmanagedType::ByValTStr, SizeConst=50)]
System::String ^Address;
[MarshalAs(UnmanagedType::ByValTStr, SizeConst=10)]
System::String ^Envelope;
[MarshalAs(UnmanagedType::ByValTStr, SizeConst=30)]
System::String ^Record;
virtual System::String^ ToString() override;
void SetDefaultValues();
};
But I cannot use
Marshal:trToStructure((IntPtr)&item, UpdateItem_); Because it has
issues apparently with the fact the managed struct is a value type. I
could copy these items manually, but this conversion is going to
happen, quite possible, in excess of 11 times a second, and gcnew'ing
these four managed strings each time is unacceptable. And I know
they're managed, and they will get Garbage Collected; but anyone when
this runs, I promise you the GC isn't running enough for me. The
memory continues to creep up, and up. Any solutions?
THank you in advance.
struct. It's a value struct and this cannot be changed.
[StructLayout(LayoutKind::Sequential, CharSet=CharSet::Ansi, Pack=1)]
public value struct UpdateItem
{
public:
[MarshalAs(UnmanagedType::ByValTStr, SizeConst=50)]
System::String ^Name;
[MarshalAs(UnmanagedType::ByValTStr, SizeConst=50)]
System::String ^Address;
[MarshalAs(UnmanagedType::ByValTStr, SizeConst=10)]
System::String ^Envelope;
[MarshalAs(UnmanagedType::ByValTStr, SizeConst=30)]
System::String ^Record;
virtual System::String^ ToString() override;
void SetDefaultValues();
};
But I cannot use
Marshal:trToStructure((IntPtr)&item, UpdateItem_); Because it has
issues apparently with the fact the managed struct is a value type. I
could copy these items manually, but this conversion is going to
happen, quite possible, in excess of 11 times a second, and gcnew'ing
these four managed strings each time is unacceptable. And I know
they're managed, and they will get Garbage Collected; but anyone when
this runs, I promise you the GC isn't running enough for me. The
memory continues to creep up, and up. Any solutions?
THank you in advance.