How to add manifest to a .NET DLL?

橙三吉。 提交于 2019-11-29 06:32:19

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

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.

The only thing that prevents you adding a manifest to a NET dll is the Visual Studio IDE. It can be circumvented very easily by modifying the .csproj directly - add the ApplicationManifest property in an appropriate property group. Add a manifest to an exe project and examine the .csproj for details.

Much easier than using MT.exe, which will replace the existing manifest (which you usually don't want to happen).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!