Lessons in this course (11)

4. Assemblies, metadata, manifest, GAC, strong names and versioning

Intermediate★ Must knowLesson 4 of 11

An assembly is the unit of deployment, versioning and security: a .dll or .exe containing:

PartContains
PE headerWindows/OS executable format
CLR headerRuntime version, entry point, flags
MetadataEvery type, method, field, parameter, attribute and referenced member — what reflection and IntelliSense read
IL codeMethod bodies
ManifestAssembly identity (name, version, culture, public key token), list of files, referenced assemblies
ResourcesEmbedded files, localised strings

Kinds: private assemblies (in the app folder — the norm today), shared assemblies in the GAC (Global Assembly Cache, .NET Framework only — C:\Windows\Microsoft.NET\assembly), satellite assemblies (localised resources, fr\MyApp.resources.dll).

Strong name = name + version + culture + public key token, signed with a key pair; required for the GAC in .NET Framework. Version format: major.minor.build.revision. Binding redirects in app.config/web.config solved "DLL hell" version conflicts in Framework; modern .NET resolves versions via NuGet and deps.json (no GAC).

xml
<!-- .NET Framework web.config binding redirect -->
<dependentAssembly>
  <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>

AppDomain vs AssemblyLoadContext: .NET Framework used AppDomains to isolate and unload code inside one process (IIS used one per web app). .NET Core removed multiple AppDomains; use AssemblyLoadContext (collectible contexts can be unloaded — plugins) or separate processes/containers for isolation.