Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add an assembly manifest to a .NET executable?
    primarykey
    data
    text
    <p>How can i add an assembly manifest to my .NET executable?</p> <hr> <p>An assembly manifest is is an XML file that is added to a .NET portable executable (PE) with resource type <code>RT_MANIFEST</code> (24). </p> <p>Assembly manifests are used to declare a number of things about the executable, e.g.:</p> <ul> <li><p>If i want to disable DPI-scaling because i am a good developer:</p> <pre><code>&lt;!-- We are high-dpi aware on Windows Vista --&gt; &lt;asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"&gt; &lt;asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"&gt; &lt;dpiAware&gt;true&lt;/dpiAware&gt; &lt;/asmv3:windowsSettings&gt; &lt;/asmv3:application&gt; </code></pre></li> <li><p>i can declare that i was designed and tested on Windows 7, and i should continue to depend on any bugs in Windows 7</p> <pre><code>&lt;!-- We were designed and tested on Windows 7 --&gt; &lt;compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"&gt; &lt;application&gt; &lt;!--The ID below indicates application support for Windows 7 --&gt; &lt;supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/&gt; &lt;/application&gt; &lt;/compatibility&gt; </code></pre></li> <li><p>i can declare that i am a good developer, and don't need file and registry virtualization</p> <pre><code>&lt;!-- Disable file and registry virtualization --&gt; &lt;trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"&gt; &lt;security&gt; &lt;requestedPrivileges&gt; &lt;requestedExecutionLevel level="asInvoker" uiAccess="false"/&gt; &lt;/requestedPrivileges&gt; &lt;/security&gt; &lt;/trustInfo&gt; </code></pre></li> <li><p>i can declare that i depend on a particular version 6 of the <strong>Microsoft Common Controls</strong> library:</p> <pre><code>&lt;!-- Dependency on Common Controls version 6 --&gt; &lt;dependency&gt; &lt;dependentAssembly&gt; &lt;assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*"/&gt; &lt;/dependentAssembly&gt; &lt;/dependency&gt; </code></pre></li> <li><p>i can declare that i depend on a particular version of GDI+:</p> <pre><code>&lt;dependency&gt; &lt;dependentAssembly&gt; &lt;assemblyIdentity type="win32" name="Microsoft.Windows.GdiPlus" version="1.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*" /&gt; &lt;/dependentAssembly&gt; &lt;/dependency&gt; </code></pre></li> </ul> <hr> <p><a href="https://stackoverflow.com/questions/8057080/vs2010-net-how-to-embed-a-resource-in-a-net-pe-executable">In the olden days</a>, we would create a <strong>resource script</strong> file (<code>*.rc</code>), e.g.:</p> <p><strong>wumpa.rc</strong></p> <pre><code> 1 24 AssemblyManifest.xml </code></pre> <p>add that file to the project, and the compiler would compile the <code>.rc</code> file; including resources in the final executable image.</p> <p>Except <a href="https://stackoverflow.com/questions/8057080/vs2010-net-how-to-embed-a-resource-in-a-net-pe-executable">Visual Studio 2010 doesn't seem to have a way to add a resource script file to a project</a>.</p> <p>How do i add a resource script to a project in Visual Studio 2010?</p> <p>How do i add an assembly manifest to a project in Visual Studio 2010?</p> <p><strong>Note</strong>: Any solution must work in an environment with source control and multiple developers (e.g. hard-coded paths to probably not installed binaries will break the build and not work).</p> <h2>Bonus Chatter</h2> <ul> <li><a href="https://stackoverflow.com/questions/8057080/vs2010-net-how-to-embed-a-resource-in-a-net-pe-executable">VS2010/.NET: How to embed a resource in a .NET PE executable?</a></li> <li>VS2005: <a href="http://blogs.msdn.com/b/cheller/archive/2006/08/24/how-to-embed-a-manifest-in-an-assembly-let-me-count-the-ways.aspx" rel="nofollow noreferrer">How to embed a manifest in an assembly: let me count the ways...</a> (can't be done)</li> </ul> <hr> <p><strong>Update</strong>: Michael Fox suggests that the project properties dialog can be used to include an assembly manifest, but he doesn't indicate <em>where</em>:</p> <p><img src="https://i.stack.imgur.com/35ZMM.png" alt="enter image description here"></p> <hr> <p><strong>Update</strong>: Things I've tried:</p> <ul> <li>From the project properties screen, select <strong>Application</strong>. Select radio option <strong>Icon and Manifest</strong>. Under <strong>Manifest</strong> leave the default option of <code>Embed manifest with default settings</code>:</li> </ul> <p><a href="https://i.stack.imgur.com/5iEt5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5iEt5.png" alt="enter image description here"></a></p> <p><em>Doesn't work because it embeds a manifest with <strong>default</strong> settings, rather than my settings.</em></p> <ul> <li><p>Under <strong>Manifest</strong>, change the combo option to <code>Create application without a manifest</code>:</p> <p><img src="https://i.stack.imgur.com/i2acY.png" alt="enter image description here"></p> <p><em>Doesn't work because it embeds no manifest</em></p></li> <li><p>Under <strong>Resources</strong> select the <strong>Resource File</strong> radio option:</p> <p><img src="https://i.stack.imgur.com/0cW3X.png" alt="enter image description here"></p> <p><em>Doesn't work because you cannot select an assembly manifest (or a resource script that includes an assembly manifest)</em></p></li> <li><p>Under <strong>Resources</strong>, select the <strong>Resource File</strong> radio option, then enter the path to an assembly manifest XML file:</p></li> </ul> <p><a href="https://i.stack.imgur.com/cZ2Sf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cZ2Sf.png" alt="enter image description here"></a></p> <p><em>Doesn't work because Visual Studio chokes when presented with an assembly manifest</em>:</p> <p><a href="https://i.stack.imgur.com/uRzHs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uRzHs.png" alt="enter image description here"></a></p> <ul> <li>Under <strong>Resources</strong>, select the <strong>Resource File</strong> radio option, then enter the path to a resource script file:</li> </ul> <p><a href="https://i.stack.imgur.com/kpcGM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kpcGM.png" alt="enter image description here"></a></p> <p><em>Doesn't work because Visual Studio chokes when presented with a resource script</em>:</p> <p><a href="https://i.stack.imgur.com/a8E6a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a8E6a.png" alt="enter image description here"></a></p> <ul> <li><p>Add the <code>AssemblyManifest.xml</code> to my project, then look for it in the <strong>Manifest</strong> combo box:</p> <p><img src="https://i.stack.imgur.com/ITG9a.png" alt="enter image description here"></p> <p><em>Doesn't work because the Assembly Manifest file isn't listed as an option</em></p></li> </ul> <blockquote> <p>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 <code>wumpa.rc</code> build action to various things, build the <code>.rc</code> file using a separate resource compiler, either manually, or a pre-build/msbuild step, and select that <code>.res</code> file as my resource). i'll stop adding extra bulk to my question and hope for an answer.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload