Search notes:

.NET assembly

A .NET assembly is the fundamental reusable building block of a common runtime language application: it exhibits a set of APIs, types and ressources that can be called or used by applications or other assemblies.
Assemblies are versionable and self-describing.
Self-describing means that all the information that the Common Language Runtime (CLR) needs to run the assembly is stored with the assembly. Such an information is for example the list of the assemblies that the assembly depends on.
An assembly is created from one or more sources and compiled into a DLL or an EXE.
An assembly is stored in the Portable Execution (PE) format: either as an EXE or a DLL.
Unllike «ordinary» DLLs however, an assembly contains MSIL-instructions that can only be executed in the .NET runtime (as opposed to machine instructions that are executed directly on a CPU).
One or more assemblies can be packed into a library.

Assembly identity and strong name

An assembly identity consists of an
If the assembly identity is augmented with the following information, it becomes a strong name:
A strong name is required for an application to be put into the Global Assembly Cache.
A strong name can be given to an assembly with sn.exe.
See also signed assemblies.
In PowerShell, some of these characteristics can be determined like so:
PS C:\> [System.Reflection.Assembly] $assembly = $true.psObject.GetType().Assembly
PS C:\> $assembly.FullName

System.Management.Automation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

PS C:\> [System.Reflection.AssemblyName] $name = [System.Reflection.AssemblyName]::GetAssemblyName($assembly.Location)
PS C:\> $name.CultureInfo

LCID             Name             DisplayName
----             ----             -----------
127                               Invariant Language (Invariant Country)

PS C:\> $name.ProcessorArchitecture

MSIL

PS C:\> $name.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
7      0      0      0
See also System.Reflection.AssemblyKeyNameAttribute and System.Reflection.AssemblyKeyFileAttribute

Assembly manifest

Every assembly contains an assembly manifest which acts as a table of content for the assembly. The manifest stores:
Additional version information about an assembly manifest can be defined with the System.Reflection.AssemblyInformationalVersionAttribute attribute.

Locating assemblies of an application

The assemblies that are used by an application are typically found
The <codeBase> element in the configuration file can be used to specify a different location.
Without a strong name, <codeBase> can only refer to the application directory or one of its subdirectories.

Finding the location of an assembly (PowerShell)

In PowerShell, the file system DLL location of an assembly that contains a given type can be determined like so:
PS C:\> [System.Data.SqlTypes.SqlDecimal].Assembly.Location
C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll

Show referenced assemblies

In PowerShell, the assemblies that an assembly references can be shown like so:
PS C:\> $asmbl = [System.Reflection.Assembly]::LoadFrom("P:\ath\to\the\assembly.dll")
PS C:\> $asmbl.GetReferencedAssemblies()

Version        Name
-------        ----
4.0.0.0        mscorlib
4.0.0.0        System.Data
1.0.0.0        YetAnotherAssembly
4.0.0.0        System

PS C:\> $asmbl.GetReferencedAssemblies().forEach( {$_.FullName} )
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
YetAnotherAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=aab5e62e1b5f9c79
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Alternatively, referenced assemblies can also be shown with the IL disassembler isldasm.exe:
C:\> ildasm P:\ath\to\the\assembly.dll
After ildadsm has opened the assmbly, the referenced assemblies are shown when opening Manifest: they are labelled with .assembly extern ….

Mixed-mode assemblies

Assemblies that were created with the C++/CLI compiler are referred to as mixed-mode assemblies because they contain both native and managed code.

Application Domains

Application domains provide isolation boundaries for assemblies. Such an isolation is used for purposes including
See also the System.AppDomain class.

Filenames of assemblies in the GAC

The filename, without its extension .dll or .exe, of an assembly that is stored in the GAC must correspond to the name of assembly itself.

Loading assemblies from the GAC

The static method LoadWithPartialName() (class System.Reflection.Assembly) loads an assembly, using a partial name, from the GAC.

See also

Powershell: Creating assemblies with add-type and then using them
Adding an assembly with the PowerShell cmdlet add-type
%windir%\Microsoft.NET\assembly
The .NET classes System.Reflection.Assembly, System.Reflection.AssemblyName and System.Reflection.Emit.AssemblyBuilder
System.AppDomain implements an event that allows to respond to loading an assembly.
HKEY_CLASSES_ROOT\Installer\Assemblies
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Managed\User SID\Installer\Assemblies
HKCU\Software\Microsoft\Installer\Assemblies
PEVerify.exe checks if an assembly contains verifiably type-safe code.
al.exe is the assembly linker
RegAsm.exe
FUSLOGVW.exe is the fusion log viewer (assembly binding log viewer) and can be used to diagnose the cause for an assembly not being able to be located by the .NET Framework at runtime.
The C# compiler command line option -link allows to specify an assembly when building an EXE or a DLL.
DB: .NET stuff/assemblies

Index