Loading modules on demand in partial trusted applications

Topics: Prism v2 - WPF 3.5
Jun 15, 2009 at 7:38 AM


I develop a XBAP application, that should run in partial trusted mode (internet zone) using the CAL framework. And I have to load modules on demand.

The following code works fine when I start the application in full trusted mode:

    public partial class Bootstrapper : UnityBootstrapper
        protected override IModuleCatalog GetModuleCatalog()
            ModuleCatalog catalog = new ModuleCatalog();

            const string moduleAssemblyQualifiedName1 = "DeviceManager.DeviceManagerModule, DeviceManager, Version=, Culture=neutral, PublicKeyToken=81447ee4612243af";
            catalog.AddModule("DeviceManager", moduleAssemblyQualifiedName1, InitializationMode.OnDemand);

            const string moduleAssemblyQualifiedName2 = "NodeManager.NodeManagerModule, NodeManager, Version=, Culture=neutral, PublicKeyToken=81447ee4612243af";
            catalog.AddModule("NodeManager", moduleAssemblyQualifiedName2, InitializationMode.OnDemand);

            return catalog;

        protected override void ConfigureContainer()

        protected override DependencyObject CreateShell()
            ShellPresenter presenter = Container.Resolve<ShellPresenter>();
            ShellMainPage shell = presenter.View as ShellMainPage;

            Container.RegisterInstance<IShellView>("ShellView", shell);
            NavigationWindow parent = shell.Parent as NavigationWindow;
            parent.ShowsNavigationUI = false;

            RegionManager.SetRegionName(shell.contentRegion, RegionNames.ContentRegion);

            RegionManager.SetRegionName(shell.leftSideBarRegion, RegionNames.LeftSideBarRegion);

            RegionManager.SetRegionName(shell.rightSideBarRegion, RegionNames.RightSideBarRegion);
            return shell;

        protected override void InitializeModules()

           IModuleManager manager = Container.Resolve<IModuleManager>();


           INodeManager nm = Container.Resolve<INodeManager>();   <== this call throws a SecurityException
           if (nm != null)
But when I start the application in partial trusted mode, it throws the following SecurityException: "Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
I already added the AllowPartiallyTrustedCallersAttribute to the CAL framework and strong named all assemblies!
Can anyone help me please??

  Thanks, Andreas


Jun 17, 2009 at 7:50 PM

Hi Andreas,


I do not know your exact scenario, but judging from the line that is throwing the exception, this issue could be related to Unity. The following article lists Unity’s v1.2 limitations when running in Partial Trust Environments:

·         Using Unity in Partial Trust Environments


You might also get some more information about this in the Unity Forums.


You should also take into account that since XBAPs are not in the scope of the Composite Application Guidance for WPF & SL, some particular things might not be fully functional.


Please let me know if this helps.


Damian Schenkelman


Jun 22, 2009 at 10:56 AM

Hi Damion,

thank you very much for your answer, it helped me to solve the problem.

The problem was, that the access modifier of my ModuleController classes was not public!

Thanks a lot,