locked
New AppDomain from MMC Snap-In does not get elevated privileges for UAC RRS feed

  • Question

  • I've created an MMC snap in that launches code in a new appdomain and part of the code checks for a registry key. If I check for the key in the snap in process it works, but the code in the new appdomain throws a security exception. If I load the code in a new appdomain from a console or windows app, it works fine. Can someone tell me what is going on here?

    Here is the code:

    public class SimpleMMCSnapIn : SnapIn
    {
    public SimpleMMCSnapIn()
    {
    RegistryKey archerKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft", true); //this call works

    Evidence baseEv = AppDomain.CurrentDomain.Evidence; Evidence newEv = new Evidence(baseEv);
    AppDomainSetup setup = new AppDomainSetup { ApplicationBase = "<pathtobin>" };
    AppDomain domain = AppDomain.CreateDomain("MigratorDomain", newEv, setup);
    domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
    IWork migrator = (IWork)domain.CreateInstanceAndUnwrap("CheckRegistry", "CheckRegistry.CheckRegistry");
    migrator.Work();
    }
    }
    [Serializable]
    public class CheckRegistry : MarshalByRefObject, IWork
    {
    public void Work()
    {
    RegistryKey archerKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft", true); //this call throws a security exception
    }
    }

    Any insight would be much appreciated...

    Brad
    • Edited by bradlogan Thursday, January 28, 2010 5:20 PM code formatting
    Thursday, January 28, 2010 5:00 PM