Export (0) Print
Expand All

Assembly.CodeBase Property

Gets the location of the assembly as specified originally, for example, in an AssemblyName object.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

Public Overridable ReadOnly Property CodeBase As String

Property Value

Type: System.String
The location of the assembly as specified originally.



To get the absolute path to the loaded manifest-containing file, use the Assembly.Location property instead.

If the assembly was loaded as a byte array, using an overload of the Load method that takes an array of bytes, this property returns the location of the caller of the method, not the location of the loaded assembly.

The following example uses the CodeBase property.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

© 2015 Microsoft