VS2008下,有一个项目,Release编译的程序可以正常运行,但是Debug编译的程序执行时提示大概这样的信息“启动程序失败,因为程序配置错误。请查看manifest文件。重装程序可能可以修复此问题。”
以前有遇到这种,现在忘了怎么解决的了,有没有人解决过这个问题的指点一下。

解决方案 »

  1.   

    project.exe.intermediate.manifest的内容如下:
    <?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.VC80.DebugCRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
        </dependentAssembly>
      </dependency>
    </assembly>
      

  2.   

    project.exe.embed.manifest的内容如下:
    <?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.VC80.DebugCRT" version="8.0.50727.762" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
        </dependentAssembly>
      </dependency>
    </assembly>
      

  3.   

    Microsoft.VC80.DebugCRT 等运行时库直接用vc安装包下的manifest,不用自己再写
      

  4.   

    进行系统日志看看,里面有错误的详细描述。控制面板->管理工具->日志查看器
      

  5.   

    检查一下工程属性里面的预定义宏,看看debug和release两种模式下是否是一样的
      

  6.   

    日志会告诉你,manifest中有什么错误。
      

  7.   

    看了系统日志,找到两个相关错误提示。顺便说一下,我的项目是从vs2005转换到VS2008下编译的第一个:
    Event Type: Error
    Event Source: SideBySide
    Event Category: None
    Event ID: 32
    Date: 2010-1-27
    Time: 10:44:46
    User: N/A
    Computer: USER-002
    Description:
    Dependent Assembly Microsoft.VC80.DebugCRT could not be found and Last Error was The referenced assembly is not installed on your system.
    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.第二个:
    Event Type: Error
    Event Source: SideBySide
    Event Category: None
    Event ID: 59
    Date: 2010-1-27
    Time: 10:44:46
    User: N/A
    Computer: USER-002
    Description:
    Generate Activation Context failed for e:\Work\Server_d.exe.Manifest. Reference error message: The operation completed successfully.
    .For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
      

  8.   

    看来是因为Microsoft.VC80.DebugCRT的运行环境找不到导致的.
    你可以在C:\WINDOWS\WinSxS目录下看看有没有对应的目录,没有的话从其他机器上拷过来即可.一般在安装了VC++05编译器的机器上会有这个目录.