pinvoke - How to set c# struct attribute (StructLayoutAttribute) globally? -


i'm working on c# p/invoke project , defining lot of structures. each structure, i'm using:

    [system.runtime.interopservices.structlayoutattribute(system.runtime.interopservices.layoutkind.sequential, pack = 1)] 

but i'd set attribute(pack = 1) once structures share same setting, how can that?

thanks, fei

you cannot that. there no global switch. have set pack explicitly on every struct.

you can @ least make code more concise adding using statement, , writing structlayout rather structlayoutattribute:

using system.runtime.interopservices;  .... [structlayout(layoutkind.sequential, pack = 1)] 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -