【问题标题】:c# Embed manifest file within .exe using mt.exe v1.0.0.0c# 使用 mt.exe v1.0.0.0 在 .exe 中嵌入清单文件
【发布时间】:2017-09-28 14:29:18
【问题描述】:

我有一个用 Visual Studio .NET 2003 制作的旧版控制台应用程序。 我试图在构建时生成的 .exe 中嵌入清单文件但没有成功,因为我想避免在我的应用程序启动时弹出 Windows 7 Ultimate 中的 UAC。

所以我的清单文件在下面,名为 MyTestApp.exe.manifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0"
     processorArchitecture="X86"
     name="IsUserAdmin"
     type="win32"/> 
  <description>SDPUpdater for ServiDirPlus</description>
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

然后在 Visual Studio .NET 2003 中,在构建后操作中,我编写以下命令:

"C:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Common7\Tools\Bin\winnt\mt.exe" -manifest "$(ProjectDir)$(TargetFileName).manifest"

考虑到:

$(ProjectDir) : C:\MyProjects\ConsoleApps\MyTestApp\
$(TargetFileName) : MyTestApp.exe

我的清单文件 MyTestApp.exe.manifest 位于 C:\MyProjects\ConsoleApps\MyTestApp\

但出现以下错误:

Performing Post-Build Event...
Microsoft (R) Side-By-Side Manifest Tool 1.0.0.0
Copyright (C) Microsoft Corporation 2000-2001.  All Rights Reserved.

Nothing to do!
Modes of operation:
   -hashupdate         Update hashes of member files
   -makecdfs           Generate CDF files to make catalogs
   -verbose            Disply piles of debugging information

Modifiers:
   -manifest <foo.man> The name of the manifest to work with

Normal usage:   mt.exe -hashupdate -makecdfs -manifest foo.man

Project error: A tool returned an error code from the build event

Post-Build Event failed

我想我必须向 mt.exe 表明我的清单文件必须嵌入 MyTestApp.exe 但我不知道如何因为 mt.exe v1.0.0.0 只有 1 个修饰符(清单),它没有提供任何方式来指示我的 MyTestApp.exe 文件。

【问题讨论】:

  • 问得太晚了 14 年。您找到了更新 VS 版本的好理由,是时候了。

标签: c# visual-studio manifest uac


【解决方案1】:

我使用过 mt.exe(Microsoft (R) Manifest Tool 版本 5.2.3790.2075)并在构建后使用此行:

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\mt.exe" -manifest "$(ProjectDir)$(TargetFileName).manifest" -outputresource:$(TargetFileName);#1

现在它编译好了。

现在,我还有一个问题:

一旦我启动控制台应用程序,uac 弹出通知就会继续出现。

我的控制台应用程序正在写入我的 C:\Program Files\ 中的一个文件夹。

但最好打开另一篇关​​于它的帖子。已解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-08
    • 2010-11-28
    • 2017-06-14
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    • 2020-10-05
    • 1970-01-01
    相关资源
    最近更新 更多