【发布时间】:2017-01-17 18:10:29
【问题描述】:
我在 Windows 64 位上使用 Visual Studio 2015。我有这个带有 C++ 后端的 WPF 项目,它使用了几个额外的包,如 OpenCV、EmguCV 和 DevExpress。
现在,如果我以Release 运行,它编译得很好。另外,如果我通过资源管理器进入当前目录并导航到bin -> Release 然后执行.exe 文件,它也可以正常运行。
问题: 该项目无法在任何其他机器上运行:如果我复制整个 Release 文件夹并将其粘贴到另一台机器上,然后尝试执行,它会弹出“无法加载文件或程序集”错误。请参阅Error Here 和下面的完整错误。
见解:那些目标机器过去能够以相同的方式(复制/粘贴或安装程序)执行发布。该项目以 .Net framework 4.5 为目标,需要 2013 + 2015 可再发行文件。一切都安装在目标机器上。此外,错误令人生气的 Dll 物理上存在于 Release 文件夹中。当我构建一个安装程序(使用Inno Setup)时,我看到所有需要的和现有的 Dll 都包含在内(OpenCv 的东西和 DevExpress)。
大约有 10 个 OpenCv Dll 未显示在“Solution Explorer -> References”中,但实际存在于 Release 文件夹中(我们将它们粘贴到它们的)。现在,如果我从我的发布文件夹中删除这些文件,我会得到完全相同的错误。另一方面,如果我将它们粘贴到他们的发布文件夹中,错误仍然存在。
所有文件的“解决方案资源管理器 -> 参考 -> 属性 -> 本地副本”都设置为 true。我目前构建为 x86,因为如果我构建为 x64,我会收到此错误:
错误 NuGet 错误:找不到包“OpenCV.overlay-x64_v120_Release”的版本“2.4.8”。 C:\Users\bla\Desktop\bla\packages\OpenCV.2.4.8\build\native\OpenCV.targets
可能是什么问题?
完全错误:
致命 @ 2016 年 9 月 9 日上午 9:18:19 - CurrentDomainOnUnhandledException v2.0.1.0 - 异常信息:System.Windows.Markup.XamlParseException: 在类型 'bla.MainWindow' 上调用构造函数 匹配指定的绑定约束抛出异常。 ---> System.IO.FileNotFoundException:无法加载文件或程序集 'bla.bla.bla.dll' 或其依赖项之一。这 找不到指定的模块。
在 bla.MainWindow..ctor()
---内部异常堆栈跟踪结束---
在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory,布尔值 skipJournaledProperties、对象 rootObject、XamlObjectWriterSettings 设置,Uri baseUri)
在 System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader,布尔型 skipJournaledProperties,对象 rootObject, XamlAccessLevel accessLevel, Uri baseUri)
在 System.Windows.Markup.XamlReader.LoadBaml(Stream 流, ParserContext parserContext, Object parent, Boolean closeStream)
在 System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream 流,ParserContext pc)
在 System.Windows.Application.LoadComponent(Uri resourceLocator, 布尔 bSkipJournaledProperties)
在 System.Windows.Application.DoStartup()
在 System.Windows.Application.<.ctor>b__1_0(未使用的对象)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托 回调,对象参数,Int32 numArgs)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object 源,委托回调,对象参数,Int32 numArgs,委托 catchHandler)
在 System.Windows.Threading.DispatcherOperation.InvokeImpl()
在 System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(对象 州)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext、ContextCallback 回调、对象状态、布尔值 preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext、ContextCallback 回调、对象状态、布尔值 preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext、ContextCallback 回调、Object 状态)
在 MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext、ContextCallback 回调、Object 状态)
在 System.Windows.Threading.DispatcherOperation.Invoke()
在 System.Windows.Threading.Dispatcher.ProcessQueue()
在 System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& 处理)
在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&handled)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托 回调,对象参数,Int32 numArgs)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object 源,委托回调,对象参数,Int32 numArgs,委托 catchHandler)
在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority 优先级、TimeSpan 超时、委托方法、对象参数、Int32 numArgs)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame 框架)
在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame 框架)
在 System.Windows.Application.RunDispatcher(对象忽略)
在 System.Windows.Application.RunInternal(Window 窗口)
在 System.Windows.Application.Run(Window 窗口)
在 bla.App.Main()
【问题讨论】:
-
尝试开启 Fusion 日志 -- hanselman.com/blog/…
-
您是否打开了 Fusion 日志?
-
@j.h 我刚开始。对不起,来晚了。我应该在目标机器上执行融合,错误在哪里?你介意去聊天室吗?
-
@FirstStep - 是的,机器有问题。我不介意去聊天室。
标签: c# wpf visual-studio visual-studio-2013 visual-studio-2015