Mirek
Mirek

Reputation: 621

C# - do I need manifest files?

I am curious whether I need two manifest files that are created when I publish my application. It works when I delete them. In the case they are needed, I have tried to embed (Project>Application>Embed manifest with default setting) them but they are still external.

Those are: (appname).exe.manifest and (appname).application.

Upvotes: 26

Views: 38322

Answers (3)

t0mm13b
t0mm13b

Reputation: 34592

Also, Back when VS2003 was used, and you want to make your controls look more like the XP interface, the manifest will contain the common controls with the appropriate version 6.x which is used along with your application, then the GUI gets a "nice updated look and feel of XP" instead of the old clunky windows 2000 controls. For that reason, you can have the manifest embedded as a resource so you do not have to lug around a manifest file (ok, it is a quite small file) but nonetheless, it makes the application distribution neater.

And also, there was a bug in the .NET 1.1 runtime (now fixed in 2.0+) where if a manifest is used at your application fails to update the GUI to give it more of an XP look and feel. The workaround at the time was to call Application.DoEvents before doing an Application.Run(new form());

Now, with Vista and Win 7, the manifest is used to specify elevated permissions to get around the UAC thereby minimizing the chance of Vista/Win 7 having to pop up an UAC dialog box.

Upvotes: 6

Jeremy McGee
Jeremy McGee

Reputation: 25210

The manifest file describes how your application should run. From MSDN:

Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other. The assembly manifest contains this assembly metadata. An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE file that contains only assembly manifest information.

So deleting them is probably the wrong thing to do, especially if you want your application to run elevated by default on Vista and beyond.

Here are details from MSDN on use of the mt tool, which is used to embed the manifest in your application.

Also note a really interesting issue concerning the caching of the manifest in Vista and beyond that looks like a real gotcha.

Upvotes: 16

Graviton
Graviton

Reputation: 83294

It is needed for the purpose of

specifying the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes

Upvotes: 1

Related Questions