ネイティブアプリケーションに古いCランタイムの使用を強制するにはどうすればよいですか

StackOverflow https://stackoverflow.com/questions/3097592

質問

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>

ロードされた.dllについてもこれを行う必要があるようです。

他のヒント

答えはから来ます 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 (DLLを変更するために2を1に置き換えます):
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が使用されていないことを確認し、アプリケーションの隣に配置します。マニフェストは、例えばに基づいています 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を介してロードされていないとCRTが不満を述べているため、アプリケーションマニフェストからアセンブリ参照を削除することはできません。

残念ながら、WinSXSからコピーされたDLLを含む、アプリケーション内のすべての依存DLLのマニフェストを変更する必要があるか、複数のバージョンがロードされる場合があります。

これが私のために機能したバッシュスクリプトです。ここで、〜/documents/sxs-hack/crt dllsと修正されたマニフェストが含まれています。

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 software microsoft windows currentversion sidebyside winners x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_none_02d0010672fd8219 9.0

デフォルトキーを必要なバージョン、例:9.0.30729.4148に設定します。 「9.0.30729.4974 "= 00」を0にしたくないバージョンを設定します。

これをCRT、ATL、MFCなどで行う必要があります。

Winsxsはポリシーをキャッシュしているようです。これは私のために機能しました:アプリケーションにタッチしてから、hkey_local_machine software microsoft windows currentversion sidebyside publisherpolicychangetimeを低いものに設定します。

これにより、システム全体の新しいランタイムが無効になります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top