c# - 无法加载文件或程序集'Microsoft.Practices.Unity,版本 = 4.0.0.0 或 Prism 7.0.0.396 是否支持 Unity 5.8.11 和 WPF?
问题描述
我继承了一个 WPF 项目,该项目使用最初用 .Net 4.5 编写的 Prism 和 Unity。我正在将项目升级到 .net 4.7.1,并将所有 Unity 和 Prism 包升级到最新版本:
- 统一 5.8.11
- Prism.Core 7.0.0.396(是 6.3.0 但 Nuget 将其升级到 7)
- 棱镜.Unity 6.3.0
- 棱镜.Wpf 6.3.0
有 5 个项目,主要项目是运行引导程序的 (WPF) 桌面应用程序。运行应用程序时出现以下错误(直接来自 bootstrapper.Run()):
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f' or one of its dependencies. The system cannot find the file specified.'
我在底部包含了完整的堆栈跟踪。
我已经搜索了我所知道的可以使用依赖信息的适当位置,即 Nuget 和 app.config 文件,但没有什么特别突出的。
堆栈跟踪中缺少的文件名是 Microsoft.Practices.Unity,但我现在拥有的所有 Unity 版本都指向 Unity.*.dll 文件。
这就引出了我的问题:Nuget 包 Prisim.Unity 是针对哪个版本的 Unity 编译的?是否支持 Unity 5.8.11?我需要添加绑定重定向吗?如果需要,我可以从源代码构建。
任何见解都会很棒,即使只是确认 Prism 6.3.0 与 Unity 5.8.11 一起使用并且我在某处犯了错误。
谢谢!拉斯
System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f' or one of its dependencies. The system cannot find the file specified.
Source=Prism.Unity.Wpf
StackTrace:
at Prism.Unity.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration)
at Prism.Bootstrapper.Run()
at MYAPP1.Desktop.App.OnStartup(StartupEventArgs e) in C:\path\to\Project\MYAPP1\App.xaml.cs:line 20
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)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
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)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at MYAPP1.Desktop.App.Main() in C:\path\to\Project\MYAPP1\obj\Debug\App.g.cs:line 51
解决方案
Nuget 包 Prisim.Unity 是针对哪个版本的 Unity 编译的?
查看Nuget,它依赖于 Unity 4.0.1
是否支持 Unity 5.8.11?
仅从 7.0.0 开始,现在是预发布版本。
所以你要么坚持使用 Prism 6.3 和 Unity 4,要么切换到预发布的 Prism 7。
推荐阅读
- git - 如何告诉 bitbake 在特定任务后计算变量的 basehash 值?
- jsf - Primefaces Chips 组件未将项目添加到列表
- python - 如果超过 88 个字符的最大长度,是否有一种格式可以在一行代码中分配多个变量?
- javascript - addEventListener('resize' 不适用于具有相对大小的 div
- python - 如何确定导致库导入缓慢的原因?
- r - 如何在 SparkR 中向 spark.lapply 传递额外的参数?
- python - Django ImportError:无法从“django.shortcuts”导入名称“render_to_response”
- pa11y - 有没有办法在一次执行 pa11y 时同时使用 Section508 和 WCAG2AA 标准?
- terminal - pdftk 不会合并多个大的 pdf
- node.js - 如何在 serverless.yml 中为 aws lambda 实现函数名称的别名?