为什么C#没有C ++风格的静态库? [英] Why does C# not have C++ style static libraries?

查看:110
本文介绍了为什么C#没有C ++风格的静态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我一直在工作共享一些公共代码一些小的.NET应用程序。该代码有介绍抽象掉 I / O单元测试调用某些接口。

Lately I've been working on a few little .NET applications that share some common code. The code has some interfaces introduced to abstract away I/O calls for unit testing.

我想要的应用程序是独立的EXE没有外部的依赖。这似乎像是一个完美的使用案例静态库。试想想它的第三方控制供应商能够从这个模型也受益。

I wanted the applications to be standalone EXEs with no external dependencies. This seems like the perfect use case for static libraries. Come to think of it third party control vendors could benefit from this model too.

有没有用,我已经错过了静态库一些隐藏的脏东西?

Are there some hidden nasties with static libraries that I've missed?

是否有任何理由,为什么C#的设计师留下出来

Is there any reason why the C# designers left them out?

编辑:我知道ILMerge,但它不提供同样的便利为静态库。

I'm aware of ILMerge but it doesn't offer the same convenience as static libraries.

推荐答案

.NET事实上确实支持静态
库的道德等价。这就是所谓的一个netmodule(文件扩展名通常是
.netmodule)。了解更多关于它在这个博客文章
当心它不能很好地在Visual Studio
编译工具链支持。我觉得扩展方法
的问题为好。 ILMerge是更好的工具来完成这个

.NET does in fact support the moral equivalent of a static library. It's called a netmodule (file extension is usually .netmodule). Read more about it in this blog post. Beware that it isn't well supported by the Visual Studio build tool chain. I think extension methods are a problem as well. ILMerge is the better tool to get this done.

这篇关于为什么C#没有C ++风格的静态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆