Как заставить собственное приложение использовать более старое время выполнения C
-
29-09-2019 - |
Вопрос
Visual Studio 2010 Устанавливает версию ... 4974 of Runtime VC9, чьи .pdbs недоступны. Анкет Как я могу заставить мой GME.exe
Чтобы использовать более старше vC9 Runtime?
Я пытался положить это в 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.
По сути, необходимо добавить приложение в базу данных совместимости с «ensablepponfig»
Это документировано здесь:
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 для 2 для модификации 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 в приложении, включая DLL, скопированные от WinSxs, или могут быть загружены несколько версий.
Вот сценарий 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 Centreversion Sidebyside Winners x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_none_02d0010672fd8219 9.0
Установите ключ по умолчанию на нужную версию, например, 9.0.30729.4148. Установите версию, которую вы не хотите 0, например, «9.0.30729.4974» = 00.
Вы должны сделать это для CRT, ATL, MFC и т. Д.
Winsxs, кажется, кэширует политику. Это работало для меня: коснитесь (1) приложение, затем установить HKEY_LOCAL_MACHINE Software Microsoft Windows Centreversion Bearbyside PublisherPolicyChangeTime на что-то низкое, например, 10.
Это отключит более новое время выполнения всей системы.