pinvoke - Can't get around compile error about fixed sized buffers in C# -
I'm trying to create some structures to copy people from some C ++ Microsoft header files. My code is as follows:
[Layout layout (layout kickind.)] Unsecured public structure _NotifyData {fixed UIT advance data [2]; Public structure data {uint cbBuf; IntPtr pBuff; }} [Strat Layout (LayoutCind.Security)] Public Structure PRINTER_NOTIFY_INFO_DATA {Public Use Type; Public service area; Public UIT Reserved; Public UIT ID; Public _NotifyData NotifyData; } [Layout layouts (Layoutkind Secure)] Unsecured public structure PRINTER_NOTIFY_INFO {public UIT version; Public UIT flags; Public UIT calculation; Fixed PRINTER_NOTIFY_INFO_DATA aData [1]; // compiler complaint here !!! } The compiler complains about my aData [1] variable about declaration of my struct PRINTER_NOTIFY_INFO . I had to face one of these encounters and in the question, the variable was set to fixed and unsafe to declare the structure apart from this framework. I get this error: Fixed size buffer type should be one of the following: bool, byte, small, int, long, four, sbyte, ushort, uint, ulong, float or double
Now I can see what I am using is not one of the listed types, but according to this, unsafe in front of the Structures declaration By inserting I want to allow other types of people to use The new one because it is not me.
You can not just declare the custom-size size range struct S in C #, error message and the page you link to (I recommend that you read it again). Edit : Incorrect information deleted. To solve this, see David Hepheran's answers.
Comments
Post a Comment