Importing Permcalc Output into the .NET Framework Configuration Tool (Mscorcfg.msc)

.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>

Print | posted @ Monday, June 12, 2006 2:00 PM

Comments on this entry:

Gravatar # re: Importing Permcalc Output into the .NET Framework Configuration Tool (Mscorcfg.msc)
by vv at 8/8/2006 5:22 AM

This tool only give full trust as requvirment.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: