Archived

This forum has been archived. Please start a new discussion on GitHub.

C#-Specific Metadata Directives

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

  • xdm
    xdm La Coruña, Spain
    chang wrote: »

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

    That should work, what is the error reported by slice2cs?
  • 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.