Converting unmanaged struct -> CLI value struct
- From: "DaTurk" <mmagdits@xxxxxxxxxxx>
- Date: 23 Feb 2007 13:08:08 -0800
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::PtrToStructure((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.
.
- Prev by Date: Re: from "general" c++ 2 visual c++ managed
- Next by Date: Re: Get CPU Fan Speed and CPU Temp
- Previous by thread: Get CPU Fan Speed and CPU Temp
- Next by thread: Dependency walker msvcr80d.dll missing coredll.dll and dwmapi.dll
- Index(es):
Relevant Pages
|