Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add manifest to a .NET DLL?

I have a c# class library project that uses a COM dll registered on the system. I now want to deploy the COM dll as a side-by-side assembly, so I don't have to register it, or interfere with other applications that might use a different version of the dll.

I have added app.manifest to the c# project using the add new item menu, but I'm not sure what to do next. In the project properties/application/icon and manifest, the manifest drop down is disabled. I don't know how to get past that. I've added a manifest file, why is it not in the dropdown list?

I have a manifest for the COM dll that works with C++ applications, and I think I keep that as is. Now I need to know how to edit the app.manifest for the c# project. I will start by adding a known good dependency element. But I need a tutorial on how to set this up, I don't see it covered anywhere.

I am using VS2008

like image 218
P a u l Avatar asked Dec 14 '09 07:12

P a u l


People also ask

What is manifest in DLL?

A manifest is some XML (typically embedded into . dll and .exe files) which can (among other things) specify the exact version of the Microsoft Visual C++ runtime (MSVCRT) that an application requires.

What is .NET manifest?

In the . NET Framework, an assembly manifest is a text file containing metadata about the code within a CLI assembly. It describes the relationship and dependencies of the components in the assembly, versioning information, scope information and the security permissions required by the assembly.


2 Answers

You definitely can embed a manifest in a .net dll. The contents of an application manifest do not all apply to an assembly, but some do. For example, the UAC entries don't make sense for a component manifest, but assemblyIdentity does.

Using the MT.EXE tool, you can embed a manifest into a dll:

Embed:

mt.exe -manifest filename.dll.manifest -outputresource:filename.dll;#2

Extract:

mt.exe -inputresource:filename.dll;#2 -out:filename.dll.extracted.manifest

Here are more links on related info:

Another dll embed example: http://msdn.microsoft.com/en-us/library/ms235591(v=VS.100).aspx

A SxS walkthrough: http://msdn.microsoft.com/en-us/library/ms973915.aspx

like image 198
LowRider2112 Avatar answered Sep 23 '22 18:09

LowRider2112


In most applications, a manifest is typically applied to EXEs/host apps - as this is the level at which one understands how all the dependent assemblies and their capabilities mesh together.

For example, in the case of setting the UAC marker via the trustinfo/security/requestedPrivileges/requestedExecutionLevel element, the case of a dependent assembly legitimately being able to say "I say we all understand about UAC" doesn't make sense.

like image 41
Ruben Bartelink Avatar answered Sep 21 '22 18:09

Ruben Bartelink