在Windows 7上从Windows 10 VS2017部署编译并找不到DLL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Windows 7上从Windows 10 VS2017部署编译并找不到DLL相关的知识,希望对你有一定的参考价值。

2.5天,我尝试了一个错误的根源,如

Could not load file or assembly "mydll.dll" or one of its dependencies.
The specified module could not be found

该项目是基于Windows C#的应用程序。该DLL是在项目内的C ++库中创建的。我使用VS2017 Entreprise在Windows 10 64位下编译,并且在Windows 7 64位下部署有问题(Windwos 10下的部署工作正常......)。所有.NET libs / exes / plugins都以.NET 4.5.2为目标(安装在deployement计算机上)。图书馆使用

Windows SDK Version: 8.1
Platform Toolset: Visual Studio 2017 (v141)

该项目创建了一个msi安装程序,我在部署计算机上成功安装。当然dll就在那里。

所以我用过程监视器观察了程序的执行情况。这个DLL似乎被加载了好几次。我最后一次看到以下内容。

"10:31:13.7703319 AM","App.exe","1412","CloseFile","C:Program Files (x86)VendorProgrammucrtbased.dll","SUCCESS",""
"10:31:13.7703575 AM","App.exe","1412","ReadFile","C:Progra mFiles (x86)VendorProgrammucrtbased.dll","SUCCESS","Offset: 1,452,544, Length: 5,120, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal"
"10:31:13.7721639 AM","App.exe","1412","CreateFile","C:Program Files (x86)VendorProgrammapi-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7722398 AM","App.exe","1412","CreateFile","C:WindowsSysWOW64api-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7723496 AM","App.exe","1412","CreateFile","C:Windowssystemapi-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7724133 AM","App.exe","1412","CreateFile","C:Windowsapi-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7725133 AM","App.exe","1412","CreateFile","C:WindowsSysWOW64api-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7725731 AM","App.exe","1412","CreateFile","C:WindowsSysWOW64api-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7726340 AM","App.exe","1412","CreateFile","C:Windowsapi-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7726991 AM","App.exe","1412","CreateFile","C:WindowsSysWOW64wbemapi-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7727622 AM","App.exe","1412","CreateFile","C:WindowsSysWOW64WindowsPowerShellv1.0api-ms-win-core-localization-l1-2-0.dll","NAME NOT FOUND","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a"
"10:31:13.7729093 AM","App.exe","1412","CloseFile","C:Program Files (x86)VendorProgrammmydll.dll","SUCCESS",""

那个api-ms-win-core-localization-l1-2-0.dll确实是由依赖者walker一起列出的

API-MS-WIN-CORE-FILE-L1-2-0.DLL
API-MS-WIN-CORE-FILE-L2-1-0.DLL
API-MS-WIN-CORE-LOCALIZATION-L1-2-0.DLL
API-MS-WIN-CORE-PROCESSTHREADS-L1-1-1.DLL
API-MS-WIN-CORE-SYNCH-L1-2-0.DLL
API-MS-WIN-CORE-TIMEZONE-L1-1-0.DLL
API-MS-WIN-DOWNLEVEL-ADVAPI32-L1-1-0.DLL
API-MS-WIN-DOWNLEVEL-OLE32-L1-1-0.DLL
API-MS-WIN-DOWNLEVEL-SHLWAPI-L1-1-0.DLL
GPSVC.DLL
MSISO.DLL

谷歌告诉我,所有这些都与这个问题无关......现在用2.5分钟的时间用nm-Dldd在2.5分钟内完成你的工作......

答案

在尝试从Windows 10有效地定位Windows 7 3天后,我分享了我的经验,我得出以下答案: 这是微软开发人员从未预见过的。 MS提供了一些黑客攻击,但无法实现可靠的开发链。

  1. 你会遇到的其他问题,看看这个link ..(严重的是你必须手动卸载Microsoft软件包以进行Microsoft更新?严重的是Microsoft?)
  2. 截至2018年,没有一个有效的工具可以告诉你在Microsoft世界中缺少什么动态库(基本上没有相当于ldd)...甚至没有开始告诉我DependecyWalker或任何东西,它让路假阳性过多(>> 100%信噪比)并且已经过时。

这与在这里不值得一提的其他1000个微软典型问题(包冲突等)一起,导致说这样做在理论上可能是可能的,但实际上并不存在。 (如果你需要花费数小时或数天的时间来完成你在Linux下几分钟内完成的事情,我认为这几乎不可行)

我对读者的建议是,如果你需要针对Win7,那么自己做一个Win7开发虚拟机。

当然,如果你的公司只能得到一个VS2017而不是2015年,就会出现问题。微软已经知道这个困境,这实际上是他们的目标。强迫您购买新产品,或者您的客户切换到新的操作系统......

Richard Critten的回答BTW与这个问题无关

以上是关于在Windows 7上从Windows 10 VS2017部署编译并找不到DLL的主要内容,如果未能解决你的问题,请参考以下文章

在 Windows 上从源代码构建 NSIS(VS2012)

PyQt5 5.8.2 在 Windows 10 上从源代码构建

Windows 10上的IE 11 VS 10上的Windows 11

如何在 Windows 7 上从 .Net 版本 2 升级到版本 4

如何在 Vista 和 Windows 7 上从我的应用程序启动屏幕键盘

Windows 7 vs 8 vs 10的用户代理[重复]