Assembly.CodeBase Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Figyelemfelhívás
Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.
Figyelemfelhívás
Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.
Lekéri a szerelvény eredetileg megadott helyét, például egy AssemblyName objektumban.
public:
virtual property System::String ^ CodeBase { System::String ^ get(); };
[System.Obsolete("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.", DiagnosticId="SYSLIB0012", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual string? CodeBase { get; }
[System.Obsolete("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.", DiagnosticId="SYSLIB0012", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual string? CodeBase { get; }
public virtual string CodeBase { get; }
public virtual string? CodeBase { get; }
[<System.Obsolete("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.", DiagnosticId="SYSLIB0012", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CodeBase : string
[<System.Obsolete("Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.", DiagnosticId="SYSLIB0012", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CodeBase : string
member this.CodeBase : string
Public Overridable ReadOnly Property CodeBase As String
Tulajdonság értéke
A szerelvény eredetileg megadott helye.
Megvalósítás
- Attribútumok
Kivételek
.NET Core és .NET 5+ csak: Minden esetben.
Példák
Az alábbi példa a tulajdonságot CodeBase használja.
using System;
using System.Reflection;
public class Example
{
public static void Main()
{
// Instantiate a target object.
Int32 integer1 = 1632;
// Instantiate an Assembly class to the assembly housing the Integer type.
Assembly systemAssembly = integer1.GetType().Assembly;
// Get the location of the assembly using the file: protocol.
Console.WriteLine("CodeBase = {0}", systemAssembly.CodeBase);
}
}
// The example displays output like the following:
// CodeBase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
Imports System.Reflection
Module Example
Public Sub Main()
' Instantiate a target object.
Dim integer1 As Integer = 1632
' Instantiate an Assembly class to the assembly housing the Integer type.
Dim systemAssembly As Assembly = integer1.GetType().Assembly
' Get the location of the assembly using the file: protocol.
Console.WriteLine("CodeBase = {0}", systemAssembly.CodeBase)
End Sub
End Module
' The example displays output like the following:
' CodeBase = file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
Megjegyzések
A betöltött jegyzékfájl abszolút elérési útjának lekéréséhez használja inkább a Assembly.Location tulajdonságot.
Ha a szerelvény bájttömbként lett betöltve, a bájttömböt használó metódus túlterhelésével Load , ez a tulajdonság a metódus hívójának helyét adja vissza, nem pedig a betöltött szerelvény helyét.
A .NET 5-ös és újabb verzióiban a csomagösszetett szerelvények esetében ez a tulajdonság kivételt jelez.