我正在 Prism WPF 中做一个项目,我想使用 fody.costura 只有一个可执行文件和一个 Prism 模块文件夹,当我将 costura 添加到项目并启动应用程序时,prism 在目录中找不到模块: .\Modules 我已经尝试了所有其他初始化模块的方法,但是引导程序没有找到它们,重要的是要说我的模块的所有依赖项都包含在初始引导项目中。
有谁知道在使用 fody.costura 时如何解决 prism 中模块的加载问题?
- - - - - - - - - - 编辑 - - - - - - - - - - - - -
我正在添加代码:
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Show();
}
protected override IModuleCatalog CreateModuleCatalog()
{
return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };
}
protected override void ConfigureModuleCatalog()
{
var moduleCatalog = (ModuleCatalog)ModuleCatalog;
}
我得到的错误是:字符串的长度不能为零。
StackTrace " en System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)\r\n en System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)\r\n en System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)\r\n en System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)\r\n en System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence)\r\n en System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)\r\n en System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)\r\n en System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)\r\n en Prism.Modularity.DirectoryModuleCatalog.InnerLoad()\r\n en Prism.Modularity.ModuleCatalog.Initialize()\r\n en Prism.Modularity.ModuleManager.Run()\r\n en Prism.Unity.UnityBootstrapper.InitializeModules()\r\n en Prism.Unity.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration)\r\n en Prism.Bootstrapper.Run()\r\n en NFE2018.App.OnStartup(StartupEventArgs e) en C:\\Users\\arman\\documents\\visual studio 2017\\Projects\\NFE2018\\NFE2018\\App.xaml.cs:línea 33\r\n en System.Windows.Application.<.ctor>b__1_0(Object unused)\r\n en System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n en System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)" string
此处出现异常:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var bootstrapper = new Bootstrapper();
bootstrapper.Run(); <-------- Here
}