Visual Studio 中的默认 .NET API
Default .NET APIs in Visual Studio
我的问题比较简单,但是网上找不到答案。 在哪里可以找到哪些 .NET API 将默认安装 visual studio,哪些需要单独安装?
例如
System.Threading.Tasks -> 使用 .Net 开发选项安装 VS 后立即可用
System.IO.Ports -> 需要单独的 NuGet 包安装才能使用
这取决于安装的 .Net 版本还是其他因素?
使用包管理器控制台,您可以检查它是否包含在内。
先查看包是否存在:
Find-Package <Your Package>
使用 System
包执行此操作会给您类似的东西:
Id Versions Description
-- -------- -----------
System.Buffers {4.5.1} Provides resource pooling of any type for performance-critical applications that allocate and deallocate objects frequently....
System.Memory {4.5.4} Provides types for efficient representation and pooling of managed, stack, and native memory segments and sequences of such s...
System.Threading.Tasks.Extensions {4.5.4} Provides additional types that simplify the work of writing concurrent and asynchronous code....
...
如果您知道包裹是真实的包裹,那么您可以跳过上面的步骤并输入:
Get-Package <Your Package>
如果它默认包含在 .NET
中,您将收到以下消息:
No packages installed.
否则你会得到类似的东西:
Id Versions Description
-- -------- -----------
MathParser.org-mXparser {4.4.2} mXparser is a super easy, rich, fast and highly flexible math expression parser library (parser and evaluator of mathematical...
Time Elapsed: 00:00:01.0141148
是的,这取决于您使用的框架版本。使用 .NET Framework 时,默认包含许多库,而在 .NET Core / .NET 5.0+ 中,其中许多函数移至单独的 nugets。一些库从某个版本开始仅作为 nugets 存在,但这些版本甚至不一定链接到特定的运行时版本(例如,即使使用 .NET 5.0 或 .NET Framework 4.8,您也可以使用 System.IO.Ports
v6.0.0)。
所以如果你需要一个类型而编译器不知道它,你需要寻找 nuget。 Microsoft 文档为每个 class 指出声明它的程序集。 nuget 通常像那个程序集一样命名。