DependencyContext Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides information about application dependencies.
public ref class DependencyContext
public class DependencyContext
type DependencyContext = class
Public Class DependencyContext
- Inheritance
-
DependencyContext
Examples
This example shows how to display the current application's target framework and run-time dependencies:
Console.WriteLine($"Target framework: {DependencyContext.Default.Target.Framework}");
Console.WriteLine();
Console.WriteLine("Runtime libraries:");
Console.WriteLine();
foreach (RuntimeLibrary lib in DependencyContext.Default.RuntimeLibraries)
{
if (lib.Dependencies.Count > 0)
{
Console.WriteLine($"{lib.Name} depends on: ");
foreach (Dependency dep in lib.Dependencies)
{
Console.WriteLine($"- {dep.Name}, Version {dep.Version}");
}
}
else
{
Console.WriteLine($"{lib.Name} does not have dependencies");
}
Console.WriteLine();
}
Remarks
When a .NET application is compiled, the SDK generates a JSON manifest file (<ApplicationName>.deps.json
) that contains information about application dependencies. You can use the DependencyContext
class to read information from this manifest at run time.
Constructors
DependencyContext(TargetInfo, CompilationOptions, IEnumerable<CompilationLibrary>, IEnumerable<RuntimeLibrary>, IEnumerable<RuntimeFallbacks>) |
Initializes a new instance of the DependencyContext class. |
Properties
CompilationOptions |
Gets the compilation options used to compile the application. |
CompileLibraries |
Gets the list of libraries used to compile the application. |
Default |
Gets the dependency context for the current application. |
RuntimeGraph |
Gets a runtime identifiers graph. |
RuntimeLibraries |
Gets the list of libraries used by the application at run time. |
Target |
Gets information about the application's target runtime. |
Methods
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
Load(Assembly) |
Loads the dependency context for the specified assembly. |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
Merge(DependencyContext) |
Merges the current dependency context with the specifed one. |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Extension Methods
Applies to
Tilbakemeldinger
https://aka.ms/ContentUserFeedback.
Kommer snart: Gjennom 2024 faser vi ut GitHub Issues som tilbakemeldingsmekanisme for innhold, og erstatter det med et nytt system for tilbakemeldinger. Hvis du vil ha mer informasjon, kan du se:Send inn og vis tilbakemelding for