如何将程序集 list 添加到我的 .NET 可执行文件?
程序集 list 是添加到资源类型为 RT_MANIFEST
的 .NET 可移植可执行文件 (PE) 中的 XML 文件。 (24)。
程序集 list 用于声明有关可执行文件的许多内容,例如:
<!-- 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>
<!-- 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>
<!-- 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>
<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 中将资源脚本添加到项目中?
如何将程序集 list 添加到 Visual Studio 2010 中的项目?
备注 :任何解决方案都必须在具有源代码控制和多个开发人员的环境中工作(例如,可能未安装的二进制文件的硬编码路径会破坏构建并且无法工作)。
奖金喋喋不休
更新 :Michael Fox 建议可以使用项目属性对话框来包含程序集 list ,但他没有指出在哪里:
更新 : 我试过的东西:
Embed manifest with default settings
的默认选项: 不起作用,因为它嵌入了带有 的 list 默认 设置,而不是我的设置。
Create application without a manifest
:不起作用,因为它没有嵌入 list
不起作用,因为您无法选择程序集 list (或包含程序集 list 的资源脚本)
不起作用,因为 Visual Studio 在显示程序集 list 时会阻塞:
不起作用,因为 Visual Studio 在呈现资源脚本时会窒息:
AssemblyManifest.xml
到我的项目,然后在 中查找它 list 组合框:不起作用,因为 Assembly Manifest 文件未作为选项列出
i have a dozen other things i can keep screenshotting (add a .rc file to the solution, look for it in the dropdown, select "no manifest" and change the
wumpa.rc
build action to various things, build the.rc
file using a separate resource compiler, either manually, or a pre-build/msbuild step, and select that.res
file as my resource). i'll stop adding extra bulk to my question and hope for an answer.
最佳答案
如果您想将自定义信息添加到应用程序的 list 中,您可以按照以下步骤操作:
这会将名为
app.manifest
的文件添加到您的项目中,您可以根据需要打开和修改该文件。类似的步骤,带有屏幕截图,从 MSDN 上的 Declaring Managed Applications As DPI-Aware 提取:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<!-- Disable file and registry virtualization. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<!-- <requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
-->
</requestedPrivileges>
</security>
</trustInfo>
<!-- 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>
<!-- Declare that we were designed to work with Windows Vista and Windows 7-->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</asmv1:assembly>
关于visual-studio-2010 - 如何将程序集 list 添加到 .NET 可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8141795/