如何向 .NET DLL 添加清单?
我有一个 c# 类库项目,它使用在系统上注册的 COM dll。我现在想要将 COM dll 部署为并行程序集,这样我就不必注册它,也不必干扰可能使用不同版本 dll 的其他应用程序。
我已使用添加新项目菜单将 app.manifest 添加到 c# 项目,但我不确定下一步要做什么。在项目属性/应用程序/图标和清单中,清单下拉列表被禁用。我不知道如何克服这一点。我已经添加了一个清单文件,为什么它不在下拉列表中?
我有一个与 C++ 应用程序一起使用的 COM dll 的清单,我想我保持原样。现在我需要知道如何编辑 c# 项目的 app.manifest。我将首先添加一个已知良好的依赖元素。但我需要一个关于如何设置它的教程,我没有在任何地方看到它。
我用的是VS2008
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您绝对可以将清单嵌入到 .net dll 中。应用程序清单的内容并不全部适用于程序集,但有些内容适用。例如,UAC 条目对于组件清单没有意义,但 assemblyIdentity 却有意义。
使用 MT.EXE 工具,您可以将清单嵌入到 dll 中:
嵌入:
提取:
以下是有关相关信息的更多链接:
另一个 dll 嵌入示例:http://msdn.microsoft.com/en-us/library/ms235591(v=VS.100).aspx
SxS 演练:http://msdn.microsoft.com/en-us/库/ms973915.aspx
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:
Extract:
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
唯一阻止您向 NET dll 添加清单的是 Visual Studio IDE。通过直接修改 .csproj 可以很容易地规避它 - 在适当的属性组中添加 ApplicationManifest 属性。将清单添加到 exe 项目并检查 .csproj 以获取详细信息。
比使用 MT.exe 容易得多,它将替换现有的清单(您通常不希望发生这种情况)。
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).
在大多数应用程序中,清单通常应用于 EXE/主机应用程序 - 因为这是人们了解所有依赖程序集及其功能如何结合在一起的级别。
例如,在通过 trustinfo/security/requestedPrivileges/requestedExecutionLevel 元素设置 UAC 标记的情况下,依赖程序集合法地能够说“我说我们都了解 UAC”的情况是没有意义的。
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.