【发布时间】:2011-11-15 19:12:39
【问题描述】:
如何将程序集清单添加到我的 .NET 可执行文件中?
程序集清单是添加到资源类型为RT_MANIFEST (24) 的.NET 可移植可执行文件(PE) 中的XML 文件。
程序集清单用于声明有关可执行文件的许多内容,例如:
-
如果我想禁用 DPI 缩放,因为我是一名优秀的开发人员:
<!-- We are high-dpi aware on Windows Vista --> <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> -
我可以声明我是在 Windows 7 上设计和测试的,我应该继续依赖 Windows 7 中的任何错误
<!-- We were designed and tested on Windows 7 --> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!--The ID below indicates application support for Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility> -
我可以声明我是一名优秀的开发人员,不需要文件和注册表虚拟化
<!-- Disable file and registry virtualization --> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> -
我可以声明我依赖于 Microsoft Common Controls 库的特定版本 6:
<!-- Dependency on Common Controls version 6 --> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*"/> </dependentAssembly> </dependency> -
我可以声明我依赖于特定版本的 GDI+:
<dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.GdiPlus" version="1.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency>
In the olden days,我们将创建一个资源脚本文件(*.rc),例如:
wumpa.rc
1 24 AssemblyManifest.xml
将该文件添加到项目中,编译器将编译.rc 文件;包括最终可执行映像中的资源。
Visual Studio 2010 doesn't seem to have a way to add a resource script file to a project 除外。
如何在 Visual Studio 2010 中将资源脚本添加到项目中?
如何在 Visual Studio 2010 中将程序集清单添加到项目中?
注意:任何解决方案都必须在具有源代码控制和多个开发人员的环境中工作(例如,可能未安装的二进制文件的硬编码路径会破坏构建并且无法工作)。
奖金聊天
- VS2010/.NET: How to embed a resource in a .NET PE executable?
- VS2005:How to embed a manifest in an assembly: let me count the ways...(做不到)
更新:Michael Fox 建议可以使用项目属性对话框来包含程序集清单,但他没有指出在哪里:
更新:我尝试过的事情:
- 从项目属性屏幕中,选择应用程序。选择单选选项图标和清单。在Manifest下保留
Embed manifest with default settings的默认选项:
不起作用,因为它嵌入了带有 默认 设置的清单,而不是我的设置。
-
在Manifest下,将组合选项更改为
Create application without a manifest:不起作用,因为它没有嵌入清单
-
在资源下选择资源文件单选选项:
不起作用,因为您无法选择程序集清单(或包含程序集清单的资源脚本)
在 Resources 下,选择 Resource File 单选选项,然后输入程序集清单 XML 文件的路径:
不起作用,因为 Visual Studio 在显示程序集清单时会阻塞:
- 在 Resources 下,选择 Resource File 单选选项,然后输入资源脚本文件的路径:
不起作用,因为 Visual Studio 在呈现资源脚本时会阻塞:
-
将
AssemblyManifest.xml添加到我的项目中,然后在Manifest 组合框中查找它:不起作用,因为 Assembly Manifest 文件未作为选项列出
我还有很多其他的东西可以继续截图(添加一个 .rc 文件到解决方案中,在下拉列表中查找它,选择“no manifest”并将
wumpa.rc构建操作更改为各种东西,构建@ 987654355@ 文件使用单独的资源编译器,手动或 pre-build/msbuild 步骤,并选择.res文件作为我的资源)。我将停止在我的问题中添加额外的内容并希望得到答案。
【问题讨论】:
-
你需要在清单中添加这一行。
在这里我给出了几个可能对你有帮助的 url。 support.microsoft.com/kb/944276professionalvisualstudio.com/blog/2007/10/05/…
标签: visual-studio-2010 manifest fusion