如何静态链接 C# ClassLibrary 的库?
我正在使用 microsoft 提供的 Dll 在 c# 中创建一个 Class LLibrary。
现在我想将 Microsoft 提供的库静态添加到 My Dll 中。我该如何执行此操作。 我只是添加了对 Microsoft 提供的 Dll 的引用并创建了 My Dll? 好不好?
如果 Microsoft 提供的 dll 在其他计算机上不可用,那么我的 Dll 可能会失败我需要静态添加库?
我怎样才能做到这一点??
I am creating a Class LLibrary in c# by using microsoft provided Dll's.
Now i want to statically add those Microsoft provided libraries to My Dll.How can i do this.
I have simply added a reference to those Microsoft provided Dlls and creating My Dll? Is it fine or not?
if Microsoft provided dll is not available on other machine then my Dll may fails i need to add the libraries statically??
How can i do this??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
.NET 中不存在静态链接到另一个程序集的情况。 有一些第三方产品(例如 .NET 链接器)可以将程序集合并为一个,但不受支持。
如果您拥有该库的重新分发许可证,则可以随程序集一起提供副本。 在 Visual Studio 中,您可以通过在该程序集引用的属性窗口中将“Copy Local”设置为“True”来实现此目的。
There's no such thing as statically linking to another assembly in .NET. There are some third party products such as .NET linker that merge assemblies into one but they are unsupported.
If you have the redistribution license for that library, you can ship a copy along with your assembly. In Visual Studio you can make this happen by setting "Copy Local" to "True" in the properties window for that assembly reference.
如果 dll 在执行时不可用; 是的,它会失败。 然而:
虽然ILMerge 可能会有用。
If the dll is not available at execution time; yes it will fail. However:
There isn't a linker provided in the core framework, although ILMerge may be useful.
它不太清楚你想要实现什么,但你似乎担心你的类库是否可以在其他机器上工作。 问题是 .Net 框架是一个免费的可再发行组件,如果目标计算机上不存在,则应安装它。 由于计算机上已经安装了 .Net 框架,因此应该不会有问题。
除了向项目添加程序集引用之外,静态链接本身在 .Net 中没有任何意义。 希望能帮助到你
Its not very clear what you want to achieve but it seems you are concerned that your class lib will work on some other machine or not. The thing is that the .Net framework is a free redistributable which should be installed if not present on the target machine. With the .Net framework already installed on a machine, there should be no problem as such.
Static linking as such does not make sense in .Net other that adding an assembly reference to your project. Hope it helps