I am using PInvoke to pass the following class to unmanaged C++ when the app starts up. All the values are passed in correctly as I step through the code. Inside the called C++ method I save a the ptr to the passed in struct.
public class Config
public int Speed;
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPStr, SizeConst = 2)]
public string Settings = new string;
Matching C++ struct
This is the method in C++ that saves ptr to the class that is passed in
void SetConfig(Config *config)
m_config = config;
Question: if the marshaller allocated memory for the C++ struct at the time of marshaling when does it free the memory?
If I save the ptr to the passed in struct, will t
View Complete Post