Home Help Center

C#-Specific Metadata Directives

changchang Member shen changOrganization: nasaProject: AMO HDU ✭✭
I try to use BinaryFormatter() or Marshal.StructureToPtr() method to convert an class object or a data structure object into byte array.
Both got errors:
(1) it is not marked as serializable
(2) it cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed

So I added a cs Metadata Directives to the class or struct, but it got errors as well. For example the following is in Ice Document but when I add it to my ice file, does not pass Slice2cs.

["cs:attribute:System.Serializable"]
struct Point {
double x;
double y;
};

Thanks

Comments

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    chang wrote: »

    ["cs:attribute:System.Serializable"]
    struct Point {
    double x;
    double y;
    };

    That should work, what is the error reported by slice2cs?
  • changchang Member shen changOrganization: nasaProject: AMO HDU ✭✭
    ignor my post

    Sorry
    The MSVS IDE red colored this line in ice file and make me thinking that Slice2cs produced error.
    It does not. After I deleted old cs file and let Slice2cs regenerate the cs file, it works now.
    It is a false error message.
Sign In or Register to comment.