c# - Marshalling .NET generic types -


Here is a C # program that tries to Marshal.SizeOf on some different types:

 using the  system; Using System.Runtime.InteropServices; Structure Layouts (LayoutCind.Security)] Class Acklace ({} Structure Layout (LayoutCind Security)] Structure Astroc {} [Layout Layout (LayoutCind.Security)] Class B {ACLs Values;} [Structure Layouts (LayoutCind.Security) ] Class C   
  "type 'c11 [AClass]' is an unmanaged structure Can not be martial in the form, no meaningful shape or offset can be made. ' 

Why? Specifically, SizeOf is referred to as C & lt; AClass & gt; , but on B or C & Edit on Edit: Because the comments were asked, here it is called "real world" There is a problem that inspires most of the academic questions: I am calling in a CPI which is basically a C function which operates a variety of simple simple structures (many different types) after all one field There is a generic header, but the area's headline R is different in different structures. One flag indicates the type of field in the header (strange, yes, but this is to work with me).

If I type a single normal type C < T & gt; and can define a single C # external declaration M (C> ), and then call M (C & LT; At & g;) and M (c & lt; double>) , I have a small and sweet interop solution but answered the answer, It appears that I Each structure has to be typed in a separate C # (although the generic headers can be provided in the heritage).

Generic forms are not supported in any interop scenario as a rule. If you try to martial a normal type or value, then both P / Attack and COM Interop will fail. So I hope that this scenario should be applied or unsupported because it is a martial-specific function.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -