This project has moved. For the latest updates, please go here.

Silverlight and FS3 StructLayout(LayoutKind.Explicit)

Aug 24, 2010 at 1:16 PM

Hi All,

Excellent work with FS3, very excited to get ported over!

I ran into an error with the Silverlight build though. I was getting "Illegal Layout Type" because of this attribute:


I get this error at runtime when trying to create the Simulator World. Anyone else running into this?

I was able to proceed by removing these attributes as well as the [FieldOffset(0)] attributes, but I'm curious if these attributes are solely for performance?




Aug 24, 2010 at 1:52 PM

Yeah I got it too... I just removed them like you did.

Aug 29, 2010 at 10:25 PM

It is needed because key and feature inside ContactID can be accessed as a union in C++. The C# way of doing it is to use a fieldoffset, and in order for that to work, we have to provide explicit structlayout.

I'm think it can be ignored for now since key is always 0, so I've put a Silverlight compiler condition in place to make it work on Silverlight. I've uploaded the modified version to the source control.

Aug 29, 2010 at 10:27 PM

Oh, and I'm sorry that I have released a non-working silverlight version of 3.0, but I don't have any silverlight tests at the moment. I thought that the StructLayout attribute would be caught by the compiler.

Aug 30, 2010 at 2:58 AM


No worries. I think that was literally the only problem I had with 3.0 in silverlight.