none
Security and MAF addons RRS feed

  • Question

  • I want to construct a WPF system that can incorporate addin developed by an external developer community. Since I can't vouch for those developers, I want their code to run in a safe environment. It seems that MAF is a good solution, so I decided to investigate the security of MAF. One can define a precise permission set for each addon, which is very nice.

    However, I want the AddOns to be able to return WPF controls. For that, they need to be able to run the WPF assemblies. In addition, I don't want the addons to be able to run unmanaged code, so that they can't override the security permissions I've set when loading the addon.

    So here's the problem - if I load the addon without permission to run unmanaged code, then the addon won't be able to create WPF controls. How can I solve this problem?

    To test this issue a bit more, I've written a small WPF app, and tried to load it and run it from a second app. Bellow is the code that loads and runs the WPF app. It works great if as is, but if I remove the last AddPermission statement (the one with the UnmanageCode flag), then it stops working, saying it can't create the window of the WPF application.

    PermissionSet set = new PermissionSet(PermissionState.None);
    set.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, PATH));
    set.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
    set.AddPermission(new UIPermission(PermissionState.Unrestricted));
    set.AddPermission(new SecurityPermission(SecurityPermissionFlag.UnmanagedCode));

    Evidence ev = new Evidence();
    AppDomain domain = AppDomain.CreateDomain("Test", ev, new AppDomainSetup() { ApplicationBase = PATH }, set);
    domain.ExecuteAssembly(PATH);

    Thursday, May 10, 2012 8:08 AM

All replies

  • Hi Palinn,

    Please post the detail exception here.

    And also, please try WPF forum: http://social.msdn.microsoft.com/Forums/en-US/wpf/threads 

    Have a nice day.


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Friday, May 11, 2012 6:45 AM
  • Cannot create instance of 'MainWindow' defined in assembly 'test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation.  Error in markup file 'MainWindow.xaml' Line 1 Position 9.

    System.Windows.Markup.XamlParseException occurred

    Sunday, May 13, 2012 6:37 AM
  • Hi Palinn,

    Welcome to the MSDN Forum.

    Based on the exception, it seems that your MainWindow.xaml file is wrong format. Please correct it at Line 1, posotion 9.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, May 14, 2012 3:55 AM
    Moderator
  • The XAML is probably fine.  It's more likely that an exception was thrown in the constructor.  If that's the case, look at the innerException of the XamlParseException to see what the actual issue is.
    Wednesday, May 16, 2012 2:02 PM