2010-06-22 55 views
4

Visual Studio 2010安装VC9运行时的版本... 4974,其版本为.pdbs are unavailable。我如何强制我的GME.exe使用较旧的VC9运行时?如何强制本机应用程序使用较旧的C运行时

我已经试过投入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. 

在Windows 7

添加 <publisherPolicy apply="no"/><dependentAssembly>结果 ERROR: Activation Context generation failed.没有其他有用的信息

注意这只是为了调试我的本地副本,而不是重新分配,所以我并不担心ab发布安全更新或发布者政策的其他好处。

回答

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> 

似乎有人需要为加载的.dll执行此操作。

6

答案来自http://blog.kalmbachnet.de/?postid=80

诀窍是从应用程序中删除体现在assemblyIdentity所以不使用WinSxS文件的publicKey属性。

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未被使用并放置它们n分机到应用程序。清单是基于例如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,或者可能会加载多个版本。

下面是对我来说,在〜/文档/的SxS-黑客/包含了CRT的DLL和修改舱单工作bash脚本:

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 
0

如果你有你总是可以静态链接的源你想使用的c运行时库...并不总是最好的想法,但如果你已经继承了一个只能在调试模式下运行并且不能重新分配调试CRT的怪兽库,它会做到这一点...

+0

请注意,根据http://msdn.microsoft.com/en-us/library/aa985618%28VS.90%29.aspx“调试版本的应用程序不可再分发”(但我不打算无论如何重新分配这个版本) – 2010-06-23 20:03:16

-1

以下是如何在Vista或7上禁用发布者策略的方法:

导航到HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ 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 \ CurrentVersion \ SideBySide \ PublisherPolicyChangeTime设置为低10.

这将禁用整个系统的较新运行时。

相关问题