My question is relatively simple, however I cannot find an answer online. Where can you find out which .NET APIs will be installed by default with visual studio, and which will need to be installed serperately?
e.g.
System.Threading.Tasks -> Available immediately after installing VS with .Net development options
System.IO.Ports -> Requires a seperate NuGet package installation to become available
Does this depend on the .Net versions installed or on some other factor?
CodePudding user response:
Using the package manager console you can check if it is included or not.
First find out if the package exists:
Find-Package <Your Package>
Doing it with the System
package will give you something like:
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....
...
If you know the package is an actual package then you can skip the step above and type:
Get-Package <Your Package>
If it is included in .NET
by default you will get the following message:
No packages installed.
Otherwise you will get something like:
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
CodePudding user response:
Yes, this depends on the framework version you use. When using .NET Framework, a lot of libraries where included by default, while in .NET Core / .NET 5.0 many of these functions where moved to separate nugets. Some libraries only exist as nugets starting from a certain version, but these versions are not even necessarily linked to a specific runtime version (e.g. you can use System.IO.Ports
v6.0.0 even with .NET 5.0 or .NET Framework 4.8).
So if you need a type and the compiler doesn't know it, you need to look for the nuget. The Microsoft documentation indicates for each class the assembly in which it is declared. The nuget is normally named like that assembly.