Opening application via Jumplist breaks Prism module dependencies

0

I'm new to .Net and WPF and I am developing something using Prism that exhibits strange behavior when I attempt to open the app via a JumpTask. My app.xaml.cs uses this to open the shell:

Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
Current.ShutdownMode = ShutdownMode.OnMainWindowClose;

Bootstrapper is:

public class Bootstrapper : MefBootstrapper
{
    protected override void ConfigureAggregateCatalog()
    {
        base.ConfigureAggregateCatalog();

        this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));
    }

    protected override IModuleCatalog CreateModuleCatalog()
    {
        return new ConfigurationModuleCatalog();
    }

    protected override DependencyObject CreateShell()
    {
        return this.Container.GetExportedValue<Shell>();
    }

    protected override void InitializeShell()
    {
        base.InitializeShell();
        Application.Current.MainWindow = (Window)this.Shell;
        Application.Current.MainWindow.Show();
    }
}

I also add a module in my app.config:

<module assemblyFile=".\EventsModule.dll" moduleType="EventsModule.Events" moduleName="Events" startupLoaded="true" />

Everything works as it should if I don't use the JumpTask item, but I receive an exception if I do - this is what is confusing me.

The JumpTask is created by this:

private void CreateJumpList()
    {
            JumpList jl = JumpList.GetJumpList(App.Current);

            if (jl == null)
            {
                jl = new JumpList();
                JumpList.SetJumpList(App.Current, jl);
            }

            JumpTask newQLTask = new JumpTask();
            newQLTask.Title = "Test";
            newQLTask.CustomCategory = Properties.Resources.JumpList_Recents;
            newQLTask.ApplicationPath = Assembly.GetEntryAssembly().Location;

            jl.JumpItems.Add(newQLTask);

            jl.Apply();                       
    }

The exception information is summarised below:

Source : Prism.Wpf

Method : HandleModuleTypeLoadingError

Type : Prism.Modularity.ModuleTypeLoadingException

Error : Failed to load type for module Events.

Error was: Could not load file or assembly 'EventsModule.dll' or one of its dependencies. The system cannot find the path specified..

Could not load file or assembly 'EventsModule.dll' or one of its dependencies. The system cannot find the path specified.

The system cannot find the path specified. (Exception from HRESULT: 0x80070003)

Stack Trace : at Prism.Modularity.ModuleManager.HandleModuleTypeLoadingError(ModuleInfo moduleInfo, Exception exception)

at Prism.Modularity.ModuleManager.IModuleTypeLoader_LoadModuleCompleted(Object sender, LoadModuleCompletedEventArgs e)

at Prism.Mef.Modularity.MefFileModuleTypeLoader.RaiseLoadModuleCompleted(LoadModuleCompletedEventArgs e)

at Prism.Mef.Modularity.MefFileModuleTypeLoader.LoadModuleType(ModuleInfo moduleInfo)

at Prism.Modularity.ModuleManager.BeginRetrievingModule(ModuleInfo moduleInfo)

at Prism.Modularity.ModuleManager.LoadModuleTypes(IEnumerable`1 moduleInfos)

at Prism.Modularity.ModuleManager.LoadModulesWhenAvailable()

at Prism.Modularity.ModuleManager.Run()

at Prism.Mef.MefBootstrapper.InitializeModules()

at Prism.Mef.MefBootstrapper.Run(Boolean runWithDefaultConfiguration)

at Prism.Bootstrapper.Run()

at App.OnStartup(StartupEventArgs e)

at System.Windows.Application.<.ctor>b__1_0(Object unused)

at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

I have tried to use FUSLOGVW but no errors relating to this issue are there.

Any help or information to further my education in this matter is greatly appreciated.

c#
.net
wpf
visual-studio
prism
asked on Stack Overflow Jan 10, 2018 by Chris • edited Jan 10, 2018 by Chris

1 Answer

0

Thanks to R.Richards comment, adding newQLTask.WorkingDirectory to the exe directory resolved the issue.

answered on Stack Overflow Jan 12, 2018 by Chris

User contributions licensed under CC BY-SA 3.0