Assembly.CodeBase Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Attention
Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.
Attention
Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.
Obtient l'emplacement de l'assembly tel qu'il a été spécifié à l'origine, par exemple dans un objet AssemblyName.
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 instead.", 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.", 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 instead.", 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.", DiagnosticId="SYSLIB0012", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CodeBase : string
member this.CodeBase : string
Public Overridable ReadOnly Property CodeBase As String
Valeur de propriété
Emplacement de l'assembly tel qu'il a été spécifié à l'origine.
Implémente
- Attributs
Exceptions
.NET Core et .NET 5 (et versions ultérieures) uniquement : Dans tous les cas.
Exemples
L’exemple suivant utilise la CodeBase propriété .
using namespace System;
using namespace System::Reflection;
void main()
{
// Instantiate a target object.
int 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
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
Remarques
Pour obtenir le chemin absolu du fichier contenant le manifeste chargé, utilisez la propriété à la Assembly.Location place.
Si l’assembly a été chargé en tant que tableau d’octets, à l’aide d’une surcharge de la Load méthode qui prend un tableau d’octets, cette propriété retourne l’emplacement de l’appelant de la méthode, et non l’emplacement de l’assembly chargé.
Dans .NET 5 et versions ultérieures, pour les assemblys groupés, cette propriété lève une exception.