Baza wiedzyCentrum egzaminacyjne
PLPolski
Wybierz język13

CKTIS / C#

System.Reflection.Assembly: odniesienie praktyczne

System.Reflection.Assembly: odniesienie praktyczne: Assembly reprezentuje załadowaną jednostkę kodu i metadanych .NET.

Wersja: .NET API; verified against .NET 10 reference surface

Składnia

System.Reflection.Assembly /* select a documented member or constructor */

Assembly reprezentuje załadowaną jednostkę kodu i metadanych .NET.

Stosuj do inspekcji typów, zasobów i nazwy bieżącego zestawu.

Dynamiczne ładowanie niesie ryzyko wykonania kodu i konfliktów kontekstu ładowania.

Location może być puste, a GetTypes może zgłosić ReflectionTypeLoadException.

Kompletny program rzeczywiście używa System.Reflection.Assembly; oczekiwany stdout to dokładnie System.Private.CoreLib.

Przykłady

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

var assembly = typeof(string).Assembly;
Console.WriteLine(assembly.GetName().Name);

Wynik

System.Private.CoreLib

Kompletny program rzeczywiście używa `System.Reflection.Assembly`; oczekiwany stdout to dokładnie `System.Private.CoreLib`.

Źródła