[解决]WPF 在 win7 系统无法运行:FileNotFoundException

时间:2022-02-06 16:47:56

开发环境:VS2015 + .NET 4.6.2

开发项目1:WPF + CefSharp

开发项目2:WPF

情况:两个项目编译的程序都无法在客户环境的 win7上运行,事件查看器中如下日志:

 The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException
at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.Assembly.Load(System.Reflection.AssemblyName)

解决流程:在重装.NET 4.0,.NET4.5.2,.NET4.6.2后,依然无法运行。后,根据网上查到的资料,说是.NET4.x + win7 的大坑。决定把版本退回到.NET4.0,在项目1重装cefsharp时,看到一句:

 Deployment:
- Make sure `Visual C++ ` is installed (`x86` or x64` depending on your build) or you package the runtime dlls with your application, see the FAQ for details.

依赖  Visual C++ 2013  的运行环境。

解决方案: 安装了   Visual C++ 2013  解决。

相关其他链接:

在.Net4.5下编译的WPF程序在Windows7下无法运行

ps:不知道我的解决方案是否适用于 上述链接作者遇到的问题。