我是.Net和WPF的新手,当我尝试通过JumpTask打开应用程序时,我正在使用Prism开发一些表现出奇怪行为的东西。我的app.xaml.cs使用它来打开shell:
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
Bootstrapper是:
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();
}
}
我还在app.config中添加了一个模块:
<module assemblyFile=".\EventsModule.dll" moduleType="EventsModule.Events" moduleName="Events" startupLoaded="true" />
如果我不使用JumpTask项目,一切都会正常工作,但如果我这样做,我会收到一个例外 - 这让我感到困惑。
JumpTask由此创建:
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();
}
异常信息总结如下:
资料来源:Prism.Wpf
方法:HandleModuleTypeLoadingError
类型:Prism.Modularity.ModuleTypeLoadingException
错误:无法加载模块事件的类型。
错误是:无法加载文件或程序集“EventsModule.dll”或其依赖项之一。系统找不到指定的路径..
无法加载文件或程序集“EventsModule.dll”或其依赖项之一。系统找不到指定的路径。
系统找不到指定的路径。 (HRESULT异常:0x80070003)
Stack Trace:at Prism.Modularity.ModuleManager.HandleModuleTypeLoadingError(ModuleInfo moduleInfo,Exception exception)
at Prism.Modularity.ModuleManager.IModuleTypeLoader_LoadModuleCompleted(Object sender,LoadModuleCompletedEventArgs e)
在Prism.Mef.Modularity.MefFileModuleTypeLoader.RaiseLoadModuleCompleted(LoadModuleCompletedEventArgs e)
在Prism.Mef.Modularity.MefFileModuleTypeLoader.LoadModuleType(ModuleInfo moduleInfo)
在Prism.Modularity.ModuleManager.BeginRetrievingModule(ModuleInfo moduleInfo)
at Prism.Modularity.ModuleManager.LoadModuleTypes(IEnumerable`1 moduleInfos)
at Prism.Modularity.ModuleManager.LoadModulesWhenAvailable()
在Prism.Modularity.ModuleManager.Run()
在Prism.Mef.MefBootstrapper.InitializeModules()
在Prism.Mef.MefBootstrapper.Run(Boolean runWithDefaultConfiguration)
在Prism.Bootstrapper.Run()
在App.OnStartup(StartupEventArgs e)
在System.Windows.Application。&lt; .ctor&gt; b__1_0(未使用的对象)
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)
我曾尝试使用FUSLOGVW,但没有与此问题相关的错误。
非常感谢任何帮助或信息以促进我在这方面的教育。
答案 0 :(得分:0)
感谢R.Richards的评论,将newQLTask.WorkingDirectory添加到exe目录解决了这个问题。