visual-studio-2010 - 如何将程序集 list 添加到 .NET 可执行文件?

标签 visual-studio-2010 manifest fusion

如何将程序集 list 添加到我的 .NET 可执行文件?

程序集 list 是添加到资源类型为 RT_MANIFEST 的 .NET 可移植可执行文件 (PE) 中的 XML 文件。 (24)。

程序集 list 用于声明有关可执行文件的许多内容,例如:

  • 如果我想禁用 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>
    
  • 我可以声明我依赖于 的特定版本 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 中将资源脚本添加到项目中?

    如何将程序集 list 添加到 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 建议可以使用项目属性对话框来包含程序集 list ,但他没有指出在哪里:

    enter image description here

    更新 : 我试过的东西:
  • 从项目属性屏幕中,选择 申请 .选择单选选项图标和 list .在 下 list 保留 Embed manifest with default settings 的默认选项:

  • enter image description here

    不起作用,因为它嵌入了带有 的 list 默认 设置,而不是我的设置。
  • 下 list , 将组合选项更改为 Create application without a manifest :

    enter image description here

    不起作用,因为它没有嵌入 list
  • 下资源 选择资源文件 单选:

    enter image description here

    不起作用,因为您无法选择程序集 list (或包含程序集 list 的资源脚本)
  • 下资源 , 选择 资源文件 单选选项,然后输入程序集 list XML 文件的路径:

  • enter image description here

    不起作用,因为 Visual Studio 在显示程序集 list 时会阻塞:

    enter image description here
  • 下资源 , 选择 资源文件 单选选项,然后输入资源脚本文件的路径:

  • enter image description here

    不起作用,因为 Visual Studio 在呈现资源脚本时会窒息:

    enter image description here
  • 添加 AssemblyManifest.xml到我的项目,然后在 中查找它 list 组合框:

    enter image description here

    不起作用,因为 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 中,您可以按照以下步骤操作:

  • 在解决方案资源管理器中右键单击项目。
  • 点击“添加新项目”。
  • 选择“应用程序 list 文件”。

  • 这会将名为 app.manifest 的文件添加到您的项目中,您可以根据需要打开和修改该文件。

    类似的步骤,带有屏幕截图,从 MSDN 上的 Declaring Managed Applications As DPI-Aware 提取:
  • 在解决方案资源管理器中,右键单击您的项目,指向 添加 ,然后单击 新建项目
  • 添加新项 对话框中,选择 应用程序 list 文件 ,然后单击 添加 。 app.manifest 文件出现。

    enter image description here
  • 将以下文本复制并粘贴到 app.manifest 文件中,然后保存。
    <?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>
    
  • 在解决方案资源管理器中,右键单击 项目 ,然后单击 属性 以验证是否使用了 app.manifest

    enter image description here
  • 您的应用程序现在显示为“为 Windows 设计”,并且是
  • 禁用文件和注册表虚拟化
  • 禁用应用程序的 DWM 缩放
  • 宣布您是在 Windows 7 和 Windows Vista 上设计和测试的
  • 依赖于公共(public)控件库版本 6(允许公共(public)控件使用视觉样式)
  • 关于visual-studio-2010 - 如何将程序集 list 添加到 .NET 可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8141795/

    相关文章:

    visual-studio-2010 - 始终未命中 Visual Studio 2010 断点

    android - 无法在 Android Studio 'R' 中解析符号 :"manifest merger failed with multiple errors, see logs"

    generics - Scala - 从泛型类型获取类对象

    visual-studio-2008 - VS2008 到 VS2010 项目升级后出现 "manifest signing certificate"错误

    c++ - boost::fusion::accumulate 简单示例

    haskell - 如何在同一个列表中融合两张 map ?

    .net - 从 .Net v4.0 程序集链接到 .Net v2.0 程序集似乎也链接(和别名)mscorlib v2.0。为什么?

    c++ - 访问多维数组元素c++

    c# - 在不锁定文件的情况下在 Winforms 中显示动画 gif

    visual-studio-2010 - Visual Studio 相对路径