Hi, As a prelude, you have to know that the ECMA-335 describes two ways to serialize security declarations.
The first one is just a blob of XML, and is usually found on assemblies prior to .net 2.0. The second one looks like a CustomAttribute, and is usually found on assemblies on and after .net 2.0. Currently, Cecil is able to read the former and the later, but only writes the later. (Which is an issue if you're roundtripping an assembly which is supposed to run on .net 1.1). On Sun, Feb 13, 2011 at 6:06 PM, [email protected] <[email protected]> wrote: > .permissionset linkcheck "<PermissionSet > class=\"System.Security.PermissionSet\"\r\n version=\"1\">\r\n <IPermission > class=\"System.Security.Permissions.StrongNameIdentityPermission, mscorlib, > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\n > version=\"1\"\r\n > PublicKeyBlob=\"002400000480000094000000060200000024000052534131000400000100010071E9D3E8FB4B521B04EA8F76D94C5FE657793FF51E88DD9DD1AD6D056525454770A74B63478A1B63ED2AD979E65BEE25DE44BA686242CE430F0C7DF1475C18BEB5467555F740961A969E5E411CA4567C73B471F32815041356C9A106309D46EF9F232CB4BB0B0746475B5DB8CE1D4FCF17D99A80A0F7205DFD03D43B109583C2\"/>\r\n</PermissionSet>\r\n" So this is a old XML permission set. > .permissionset linkcheck = {class > 'System.Security.Permissions.PermissionSetAttribute' = {property string > 'XML' = string('<PermissionSet class=\"System.Security.PermissionSet\"\r\n > version=\"1\">\r\n <IPermission > class=\"System.Security.Permissions.StrongNameIdentityPermission, mscorlib, > Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\n > version=\"1\"\r\n > PublicKeyBlob=\"002400000480000094000000060200000024000052534131000400000100010071E9D3E8FB4B521B04EA8F76D94C5FE657793FF51E88DD9DD1AD6D056525454770A74B63478A1B63ED2AD979E65BEE25DE44BA686242CE430F0C7DF1475C18BEB5467555F740961A969E5E411CA4567C73B471F32815041356C9A106309D46EF9F232CB4BB0B0746475B5DB8CE1D4FCF17D99A80A0F7205DFD03D43B109583C2\"/>\r\n</PermissionSet>\r\n')}} Which gets written as a 2.0 security declaration. > So it seems like cecil has problems with copying such SecurityDeclarations. > What I do in the merge process is simply copying the SecurityDeclaration by > cloning it (creating a new one and adding all fields and properties, which > are cloned, too). However, the above result is the same when just copying > the SecurityDeclaration from the original assembly. And even if they look different, the output assembly should work, doesn't it? > Pure roundtripping (read assembly with ReadingMode.Immediate, write to > another location) works, but I guess cecil does not touch the > SecurityDeclarations in this case? Indeed, it just copies the blob. Jb -- -- mono-cecil
