Можно ли заставить mt.exe правильно встраивать файлы манифеста в Visual Studio 2008? - PullRequest
2 голосов
/ 18 марта 2010

Я обнаружил, что mt.exe не может правильно создавать и встраивать файлы манифеста в исполняемые файлы при запуске внутри VCPROJ.

Например, тот же исполняемый файл хорошо загружается в Windows 7, но не удается загрузить в Windows XP. Манифест был встроен и правильный.

Место, где оно терпит неудачу, находится внутри crtlib.c:

if (!(*pfnFindActCtxSectionStringW)(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, _CRT_DLL_FILENAME, &askd))

Это отправило меня на http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/2d6af19a-6ead-4c00-a896-871a28c5f7f1

Я трачу много часов на поиск возможных причин и решения. Я изменил настройки проекта, чтобы сгенерировать манифест вне exe-файла. Теперь он работает на обеих системах.

Вот примеры отладочных сборок.

С отключенным встраиванием:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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.DebugCRT" version="9.0.21022.8" processorArchitecture="x86"     publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC90.DebugMFC" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>

Это с включенным встраиванием:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
<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" /> 
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" /> 
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.DebugMFC" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" /> 
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*" /> 
</dependentAssembly>
</dependency>
</assembly>

Если вы сравните их, второй добавляет общие элементы управления (я не знаю, откуда), а также это небольшая разница с синтаксисом тега requiredExecutionLevel.

Теперь вопрос, можно ли заставить mt.exe правильно встраивать манифесты и как?

...