Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Sandboxing with AppDomain

Sandboxing with AppDomain

Scheduled Pinned Locked Moved C#
questionworkspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    softwarejaeger
    wrote on last edited by
    #1

    Hello, i want to restrict the file-access for the "IPlugin"-Object (except the same folder where the assembly is in), which i load over my AppDomain from another Assembly (which is in the same bin folder as the host-app). But the "IPlugin"-Instance can write over "finder.PerformAction(null)" everywhere Oo what i'm doing wrong?

       PermissionSet ps = new PermissionSet(PermissionState.None);
            ps.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
            FileIOPermission fP = new FileIOPermission(PermissionState.None);
            fP.AllFiles = FileIOPermissionAccess.NoAccess;
            fP.AddPathList(FileIOPermissionAccess.PathDiscovery | FileIOPermissionAccess.Read, Environment.CurrentDirectory);
    
    
            ps.AddPermission(fP);
            
    
    
                AppDomainSetup ads = new AppDomainSetup();
                ads.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
                AppDomain domain = AppDomain.CreateDomain("Plugins", AppDomain.CurrentDomain.Evidence, ads, ps, CreateStrongName(System.Reflection.Assembly.GetExecutingAssembly()));
                IPlugin finder = (IPlugin)domain.CreateInstanceFromAndUnwrap("MyPluginTest.dll", "MyPluginTest.IPluginTest");
                finder.PerformAction(null);
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups