无法加载文件或程序集'Microsoft.Practices.Unity,版本=4.0.0.0 或 Prism 7.0.0.396 是否支持带有 WPF 的 Unity 5.8.11?

Could not load file or assembly 'Microsoft.Practices.Unity, Version=4.0.0.0 OR Is Unity 5.8.11 supported for Prism 7.0.0.396 with WPF?

我继承了一个使用Prism 和Unity 的WPF 项目,该项目最初是用.Net 4.5 编写的。我正在将项目升级到 .net 4.7.1,并将所有 Unity 和 Prism 包升级到最新版本:

有 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

What version of Unity is the Nuget package Prisim.Unity compiled against?

查看Nuget,依赖Unity 4.0.1

Is Unity 5.8.11 supported?

仅从 7.0.0 开始,现在是预发布。

因此,您要么坚持使用 Prism 6.3 和 Unity 4,要么切换到预发布版 Prism 7。