Assembly.CodeBase Proprietà
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Attenzione
Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead.
Attenzione
Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.
Ottiene il percorso dell'assembly come originariamente specificato, ad esempio in un oggetto 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
Percorso dell'assembly come originariamente specificato.
- Attributi
Solo .NET Core e .NET 5+: In tutti i casi.
Nell'esempio seguente viene usata la CodeBase proprietà .
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
Per ottenere il percorso assoluto del file manifesto contenente il file, usare invece la Assembly.Location proprietà .
Se l'assembly è stato caricato come matrice di byte, usando un overload del Load metodo che accetta una matrice di byte, questa proprietà restituisce la posizione del chiamante del metodo, non la posizione dell'assembly caricato.
In .NET 5 e versioni successive, per gli assembly in bundle, questa proprietà genera un'eccezione.
Prodotto | Versioni (Obsoleto) |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1 (5, 6, 7, 8, 9) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.5, 1.6, 2.0, 2.1 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: