我如何强制本机应用程序使用较旧的C运行时间
-
29-09-2019 - |
题
Visual Studio 2010安装版本... VC9运行时的4974 .pdbs不可用. 。我该如何强迫我 GME.exe
使用较旧的VC9运行时?
我尝试将其放入 GME.exe.config
:
<?xml version="1.0"?>
<configuration>
<windows>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity type="win32" name="GME" processorArchitecture="x86" version="1.0.0.1"/>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" publicKeyToken="1fc8b3b9a1e18e3b" processorArchitecture="x86" />
<bindingRedirect oldVersion="9.0.21022.8-9.0.21022.4974" newVersion="9.0.30729.4148" />
<bindingRedirect oldVersion="9.0.30729.0-9.0.30729.4974" newVersion="9.0.30729.4148" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.MFC" publicKeyToken="1fc8b3b9a1e18e3b" processorArchitecture="x86" />
<bindingRedirect oldVersion="9.0.21022.8-9.0.21022.4974" newVersion="9.0.30729.4148" />
<bindingRedirect oldVersion="9.0.30729.0-9.0.30729.4974" newVersion="9.0.30729.4148" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.ATL" publicKeyToken="1fc8b3b9a1e18e3b" processorArchitecture="x86" />
<bindingRedirect oldVersion="9.0.21022.8-9.0.21022.4974" newVersion="9.0.30729.4148" />
<bindingRedirect oldVersion="9.0.30729.0-9.0.30729.4974" newVersion="9.0.30729.4148" />
</dependentAssembly>
</assemblyBinding>
</windows>
</configuration>
但是,SXSTRACE报告:
INFO: Resolving reference Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
....
INFO: Publisher Policy redirected assembly version.
添加 <publisherPolicy apply="no"/>
在下面 <dependentAssembly>
结果是 ERROR: Activation Context generation failed.
在Windows 7上没有其他有用的信息。
请注意,这仅用于调试我的本地副本,而不是重新分配,因此我不必担心出版商策略的安全更新或其他好处。
解决方案 2
这是使应用程序配置与Win2003一起使用的技巧,然后以后:
http://www.tech-archive.net/archive/vc/microsoft.public.vc.ide_general/2008-01/msg00033.html
本质上,需要将应用程序添加到兼容性数据库中,以“ EnableAppConfig”
这在这里记录了:
http://msdn.microsoft.com/en-us/library/ee710783%28vs.85%29.aspx
在职的 GME.exe.Config
:
<?xml version="1.0"?>
<configuration>
<windows>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
<publisherPolicy apply="no"/>
<bindingRedirect oldVersion="9.0.21022.0-9.0.21022.4974" newVersion="9.0.30729.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.MFC" publicKeyToken="1fc8b3b9a1e18e3b" processorArchitecture="x86"/>
<publisherPolicy apply="no"/>
<bindingRedirect oldVersion="9.0.21022.0-9.0.21022.4974" newVersion="9.0.30729.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.ATL" publicKeyToken="1fc8b3b9a1e18e3b" processorArchitecture="x86"/>
<publisherPolicy apply="no"/>
<bindingRedirect oldVersion="9.0.21022.0-9.0.21022.4974" newVersion="9.0.30729.1" />
</dependentAssembly>
</assemblyBinding>
</windows>
</configuration>
似乎也需要为加载.dlls做到这一点。
其他提示
答案来自 http://blog.kalmbachnet.de/?postid=80
诀窍是从应用程序中删除 publicKey
属性 assemblyIdentity
因此不使用winsxs。
GME.exe.manifest
:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.4148" processorArchitecture="x86">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.MFC" version="9.0.30729.4148" processorArchitecture="x86">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.ATL" version="9.0.30729.4148" processorArchitecture="x86">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*">
</assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
将清单嵌入 GME.exe
(用1代替1用于修改DLL):
mt -manifest GME.exe.manifest -outputresource:GME.exe;1
然后复制必要的dll:
cp -a windows/winsxs/x86_microsoft.vc90.{atl,crt,mfc}*30729.4148*/*dll path-to-app/
然后为每个组件创建清单,即不使用SXS并将其放在应用程序旁边。清单基于EG C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2.manifest
:
Microsoft.VC90.CRT.Manifest
:
<?xml version="1.0"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.4148" processorArchitecture="x86"></assemblyIdentity>
<file name="msvcr90.dll"></file>
<file name="msvcp90.dll"></file>
<file name="msvcm90.dll"></file>
</assembly>
由于CRT抱怨它没有通过SXS加载,因此无法从应用程序清单中删除汇编引用。
不幸的是,似乎必须修改应用程序中每个依赖性DLL的清单,包括从WINSXS复制的DLL或可以加载多个版本。
这是一个对我有用的bash脚本,其中〜/documents/sxs-hack/包含CRT DLL和修改的清单:
rm -rf bin
mkdir bin
cp -a ~/Documents/sxs-hack/* bin/
find -iname \*.dll -or -iname \*.ocx -or -iname \*.exe | while read -r file; do
cp -a "$file" bin/"$(basename $file)"
export file=bin/"$(basename $file)"
export res=$file\;2
if [ ${file:${#file}-3} = "exe" ]; then export res=$file\;1; fi
echo $file
mt.exe -nologo -inputresource:"$res" -out:extracted.manifest &&
perl -pli -e 's/(Microsoft.VC90.[^>]*)version="[^"]*"([^>]*)publicKeyToken="[^"]*"/$1 $2 version="9.0.30729.4148"/g;' extracted.manifest &&
mt -nologo -manifest extracted.manifest -outputresource:"$res"
regsvr32 /s "$file" || true
done
如果您有来源,您总是可以静态地链接要使用的C-Runtime库...并非总是最伟大的主意重新分配调试CRT,它将解决问题...
这是禁用Vista或7的发布者政策的方法:
导航到hkey_local_machine 软件 Microsoft Windows Windows CurrentVersion SideByside Winners winners x86_policy.9.0.9.0.microsoft.vc90.crt_1fc8b3b9aa1e18e18e3b_none_none_02d00001010672fdd88219 9.019.0.0
将默认键设置为您想要的版本,例如9.0.30729.4148。将您不想0的版本设置为0,例如“ 9.0.30729.4974” = 00。
您必须为CRT,ATL,MFC等执行此操作。
WinSXS似乎可以缓存政策。这对我有用:触摸(1)应用程序,然后将HKEY_LOCAL_MACHINE SOFTWORT MICROSOFT WINDOWS CurrentVersion SideByside PublisherPolicyChangeTime设置为低点,例如10。
这将禁用整个系统的较新运行时。