title: Is possible to make mt.exe embed manifest files correctly in Visual Studio 2008?
body: <p>I found that <code>mt.exe</code> fails to correctly create and embed manifest files into executables when run inside a VCPROJ.</p>
  
  <p>For example the same executable load well on Windows 7 but failed to load on Windows XP. The manifest was embedded and correct. </p>
  
  <p>The place where it fails is inside <code>crtlib.c</code>:</p>
  
  <pre><code>if (!(*pfnFindActCtxSectionStringW)(0, NULL, ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, _CRT_DLL_FILENAME, &amp;askd))
  </code></pre>
  
  <p>This sent me to <a href="http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/2d6af19a-6ead-4c00-a896-871a28c5f7f1" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/2d6af19a-6ead-4c00-a896-871a28c5f7f1</a></p>
  
  <p>I spend lots of hours searching for possible reasons and solution I modified the project settings to generate the manifest outside the exe file. Now it works on both systems.</p>
  
  <p>Here are the examples for debug builds.</p>
  
  <p>With embed disabled:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"&gt;
    &lt;trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"&gt;
      &lt;security&gt;
        &lt;requestedPrivileges&gt;
          &lt;requestedExecutionLevel level="asInvoker" uiAccess="false"&gt;&lt;/requestedExecutionLevel&gt;
        &lt;/requestedPrivileges&gt;
      &lt;/security&gt;
    &lt;/trustInfo&gt;
    &lt;dependency&gt;
      &lt;dependentAssembly&gt;
        &lt;assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86"     publicKeyToken="1fc8b3b9a1e18e3b"&gt;&lt;/assemblyIdentity&gt;
      &lt;/dependentAssembly&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;dependentAssembly&gt;
        &lt;assemblyIdentity type="win32" name="Microsoft.VC90.DebugMFC" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"&gt;&lt;/assemblyIdentity&gt;
      &lt;/dependentAssembly&gt;
    &lt;/dependency&gt;
  &lt;/assembly&gt;
  </code></pre>
  
  <p>This is with embed enabled:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt; 
  &lt;assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"&gt;
  &lt;trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"&gt;
  &lt;security&gt;
  &lt;requestedPrivileges&gt;
  &lt;requestedExecutionLevel level="asInvoker" uiAccess="false" /&gt; 
  &lt;/requestedPrivileges&gt;
  &lt;/security&gt;
  &lt;/trustInfo&gt;
  &lt;dependency&gt;
  &lt;dependentAssembly&gt;
  &lt;assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" /&gt; 
  &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
  &lt;dependentAssembly&gt;
  &lt;assemblyIdentity type="win32" name="Microsoft.VC90.DebugMFC" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" /&gt; 
  &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
  &lt;dependentAssembly&gt;
  &lt;assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*" /&gt; 
  &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
  &lt;/assembly&gt;
  </code></pre>
  
  <p>If you compare them the second one adds common controls (I don't know from where) and also it is a small difference with the syntax of requestedExecutionLevel tag.</p>
  
  <p>Now the question is if it is possible to make mt.exe embed correctly the manifests and how?</p>