How do I create/edit a Manifest file?
Asked Answered
F

6

131

I have this code from a coworker (probably got it from the web somewhere) but he's out on vacation and I need to add this to the manifest file

<?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" />
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
            <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
                <requestedExecutionLevel level="requireAdministrator" 
        uiAccess="false" />
            </requestedPrivileges>
        </security>
    </trustInfo>
</asmv1:assembly>  

I am relatively new to this so any help would be appreciated. Thanks

I'm using Visual Studio 2010

Falsework answered 18/5, 2011 at 20:13 Comment(1)
possible duplicate of How to force C# App to run as administrator on Windows 7Sawfish
S
164

In Visual Studio 2010 and possibly in future versions you can add the manifest file to your project.

Right click on your project file on the Solution Explorer, select Add, then New item (or CTRL+SHIFT+A). There you can find Application Manifest File.

The file name is app.manifest. app manifest icon

If this item doesn't exist then your project type is not conform with a manifest file, e.g. web application.

Syd answered 18/5, 2011 at 20:17 Comment(7)
Thank you but I don't know how to create the file properly.Falsework
Ibram's instructions also apply to Visual Studio 2012.Tadpole
and Visual Studio 2013 as well.Envy
Cocoa, It creates a default manifest. You are able to change things in it (such as "program requires admin execution level") but you are free to keep it defaultPrognosis
It may be worth mentioning, that using the default manifest which is created by this method and which contains the node "<assemblyIdentity version="1.0.0.0" name="MyApplication" /> as above makes at least not much sense and is confusing at least. I am not sure, if this could be even the source of further problems as the assemblyname and version in the manifest could be false and not taken from 'AssemblyInfo.cs' ? I use only the parts which make sense of that "template". Especially I am adding the operating system keys, e.g. for Win 10 which even VS 2013 doesn't know yet.Tiloine
I wonder where the Application Manifest File template comes from, because there is nothing with that name (or even with manifest in the name) when I followed those instructions and looked at every branch of the new item type tree. I'm using VS2019 16.11.5 (and started with v16.0.0, followed by every update) but I only install what I need to develop native C/C++ projects for Windows. I must need to install something I don't need to get this thing that I kinda need... Sigh.Tse
@SteveValliere The manifest file could only be used in the .NET framework. I think you can't use it in a native C/C++ project.Syd
E
41

As ibram stated, add the manifest thru solution explorer:

enter image description here

This creates a default manifest. Now, edit the manifest.

  • Update the assemblyIdentity name as your application.
  • Ask users to trust your application

enter image description here

  • Add supported OS

enter image description here

Exsect answered 4/3, 2016 at 16:53 Comment(1)
The <applicationRequestMinimum> node does not come up be default? Is it something you have added for a reason? I am using VS2015Cyclops
F
15

The simplest way to create a manifest is:

  1. Project Properties -> Security -> Click "enable ClickOnce security settings"
    (it will generate default manifest in your project Properties)
  2. then Click it again in order to uncheck that Checkbox
  3. open your app.maifest and edit it as you wish.

Manifest location preview

Freehold answered 1/4, 2019 at 19:19 Comment(3)
This appears to no longer be creating a manifest (VS 2019, .Net 4.7, WinForms application).Pheidippides
@VioletGiraffe Tested right now with VS 2019, .NET 4.7.2 and Winforms(.NET Framework) and still works as expected.Freehold
Thank you for testing. It seems that the manifest file actually is created on the disk, but not included into the project automatically.Pheidippides
T
4

In Visual Studio 2019 WinForm Projects, it is available under

Project Properties -> Application -> View Windows Settings (button)

enter image description here

Transition answered 6/3, 2020 at 13:39 Comment(0)
B
3

In Visual Studio 2022 WinForm Project, it is also available under

Project Properties -> Application:

enter image description here

Backpack answered 22/3, 2022 at 2:38 Comment(0)
B
1

Go to obj folder in you app folder, then Debug. In there delete the manifest file and build again. It worked for me.

Besides answered 20/8, 2017 at 10:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.