Geeks With Blogs
David Douglass .NET on My Mind

.NET Framework 2.0 includes permcalc.exe, a tool for calculating the minimum permissions that an assembly needs to run.  The output is an XML file that you might want to import into the .NET Framework Configuration Tool (Mscorcfg.msc).  But the two tools use slightly different formats!  Thus, a command like:

permcalc -Sandbox TestRegistrySecurity.exe

produces a file like:

<?xml version="1.0"?>
<Sandbox>
    <PermissionSet
    version="1"
    class="System.Security.PermissionSet">
        <IPermission
        version="1"
        class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        Flags="UnmanagedCode, Execution" />

<IPermission version="1" class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Unrestricted="true" /> </PermissionSet> </Sandbox>


which won't import.  To make it importable, the following changes need to be made:

1. Remove the XML declaration
2. Remove the Sandbox tag
3. Add Name attribute.  This isn't required, but the generated name isn't very good.
4. Add Description attribute.  This is optional.

For example, the above file becomes:

<PermissionSet
Name="Permission Import Demo"
Description="from fixed up permcalc results"
version="1"
class="System.Security.PermissionSet">
    <IPermission
    version="1"
    class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    Flags="UnmanagedCode, Execution" />

<IPermission version="1" class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Unrestricted="true" /> </PermissionSet>
Posted on Monday, June 12, 2006 2:00 PM | Back to top


Comments on this post: Importing Permcalc Output into the .NET Framework Configuration Tool (Mscorcfg.msc)

# re: Importing Permcalc Output into the .NET Framework Configuration Tool (Mscorcfg.msc)
Requesting Gravatar...
This tool only give full trust as requvirment.
Left by vv on Aug 08, 2006 5:22 AM

Your comment:
 (will show your gravatar)


Copyright © David Douglass | Powered by: GeeksWithBlogs.net