On Fri, 12 Apr 2002 16:45:52 -0600, Mike Woodring <[EMAIL PROTECTED]> wrote:
<snip/> I'm wondering if the issue with nothing showing up in .permissionset is due to the way the set is calculated. Take a look at this code: FileStream fs1 = new FileStream(@"d:\assembly\CallerA.snk", FileMode.Open); StrongNameKeyPair snkp1 = new StrongNameKeyPair(fs1); StrongNamePublicKeyBlob p1Blob = new StrongNamePublicKeyBlob (snkp1.PublicKey); StrongNameIdentityPermission s1 = new StrongNameIdentityPermission(p1Blob, "CallerA", new Version()); FileStream fs2 = new FileStream(@"d:\assembly\CallerB.snk", FileMode.Open); StrongNameKeyPair snkp2 = new StrongNameKeyPair(fs2); StrongNamePublicKeyBlob p2Blob = new StrongNamePublicKeyBlob (snkp2.PublicKey); StrongNameIdentityPermission s2 = new StrongNameIdentityPermission(p2Blob, "CallerB", new Version()); PermissionSet psSNAdd = new PermissionSet(PermissionState.None); psSNAdd.AddPermission(s1); Console.WriteLine("With just s1: " + psSNAdd.ToXml().ToString()); psSNAdd.AddPermission(s2); Console.WriteLine("With both: " + psSNAdd.ToXml().ToString()); FileIOPermission f1 = new FileIOPermission(FileIOPermissionAccess.Read, @"C:\Program Files"); FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Write, @"C:\ADirectory"); PermissionSet psFileAdd = new PermissionSet(PermissionState.None); psFileAdd.AddPermission(f1); Console.WriteLine("With just f1: " + psFileAdd.ToXml().ToString()); psFileAdd.AddPermission(f2); Console.WriteLine("With both: " + psFileAdd.ToXml().ToString()); If you look at the XML output of psSNAdd before s2 is added, it contains the StrongNameIdentityPermission. After s2 is added, nothing exists in the PermissionSet. With two FileIOPermissions, this doesn't happen - in the code, psFileAdd will contain both (it combines both permissions into one but the semantics are still there). I'm curious if the C# compiler is using a PermissionSet to calculate a permission set for permissions added to the code. Granted, psSNAdd will contain some XML after s2 is added, but the # of permissions in psSNAdd is 0, so maybe the compiler just says, "well, there's nothing in the set, so that's what I'll add." Completely hypothetical, I know :). Just something that crossed my mind. Regards, Jason You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.