c# - Visual Studio 2015 中的共享项目和类库有什么区别?

标签 c# .net visual-studio-2015

我一直在查看 Visual Studio 2015 的新功能和共享项目,但我不明白它与使用类库或可移植类库有何不同。谁能解释一下?

编辑:共享项目是 Visual Studio 2015 中的一项新功能,不同于可移植类库。我了解什么是可移植类库。我想了解的是共享项目与类库有何不同。请参阅下面的链接。

http://www.c-sharpcorner.com/UploadFile/7ca517/shared-project-an-impressive-features-of-visual-studio-201/

最佳答案

共享项目和类库的区别在于后者是编译的,重用的单位是程序集。

而对于前者,重用的单位是源代码,共享代码被合并到引用共享项目的每个程序集中。

当您想要创建针对特定 平台但仍有代码应共享的单独程序集时,这会很有用。

另见 here :

The shared project reference shows up under the References node in the Solution Explorer, but the code and assets in the shared project are treated as if they were files linked into the main project.


在以前版本的 Visual Studio1 中,您可以通过添加 -> 现有项然后选择链接来在项目之间共享源代码。但这有点笨拙,每个单独的源文件都必须单独选择。为了支持多个不同的平台(iOS、Android 等),他们决定通过添加共享项目的概念来更轻松地在项目之间共享源代码。


1 这个问题和我的回答(到目前为止)表明共享项目是 Visual Studio 2015 中的一项新功能。事实上,它们在 Visual Studio 2013 Update 2 中首次亮相。

关于c# - Visual Studio 2015 中的共享项目和类库有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30634753/

相关文章:

c# - Assembly.GetTypes() 的行为在 Visual Studio 2015 中发生了变化

c++ - Visual Studio 2015 (C++) : lock search word (ctrl+F) for all . cpp/.h

asp.net - Microsoft.CodeDom.Providers.DotNetCompilerPlatform v1.0.6

c# - 从 C# SelectList 中获取文本项

c# - Entity Framework 4.1 中带有 TransactionScope 的多个 dbcontext 的 SaveChanges()

c# - 为什么 "CreateCommand()"不是 C#(或至少是 .NET)的一部分?

.net - 如何将 MoneyBookers 与 ASP.NET 应用程序集成?

c# - 我应该如何处理停止的、死亡的线程?活着 == 假

javascript - 数据模型未在 Controller 中反序列化

c# - ExcelCom 将公式写入单元格会导致#name?