AssemblyLoader 1.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package AssemblyLoader --version 1.2.1                
NuGet\Install-Package AssemblyLoader -Version 1.2.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AssemblyLoader" Version="1.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AssemblyLoader --version 1.2.1                
#r "nuget: AssemblyLoader, 1.2.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AssemblyLoader as a Cake Addin
#addin nuget:?package=AssemblyLoader&version=1.2.1

// Install AssemblyLoader as a Cake Tool
#tool nuget:?package=AssemblyLoader&version=1.2.1                

AssemblyLoader

Assembly Information & Loader via Reflection


Description
CREATED BY: Latency McLaughlin
UPDATED: 4/8/2024
FRAMEWORK: [net452], [netstandard2.0], [netstandard2.1] ([Latest])
LANGUAGE: [C#] preview
OUTPUT TYPE: Library [API]
SUPPORTS: [Visual Studio]
GFX SUBSYS: [None]
TAGS: [AssemblyLoader C# AssemblyInfo]
STATUS .NET
LICENSE: License
VERSION: GitHub Release

<hr>

  • <a href="#introduction">Introduction</a>
  • <a href="#history">History</a>
  • <a href="#solution">Solution</a>
  • <a href="#usage">Usage</a>
  • <a href="#installation">Installation</a>
  • <a href="#license">License</a>

<hr>

<h2><a name="introduction">Introduction</a></h2>

Gets assembly information at runtime commonly found in Properties within .NET assemblies. Dynamically loads / unloads assemblies and their dependencies within a proxy for validation.

<h2><a name=history">History</a></h2>

Trying to get information out of an assembly without loading it into the current application domain is not that simple. There is no way to get custom assembly attributes without loading it into the current AppDomain. There is a special assembly loading method, <i>Assembly.ReflectionOnlyLoad()</i>, which uses a "reflection-only" load context. This lets you load assemblies that cannot be executed, but can have their metadata read. You cannot get typed attributes from this kind of assembly, only CustomAttributeData. That class doesn't provide any good way to filter for a specific attribute.

Even worse, a reflection-only load does not load any dependency assemblies, but it forces you to do it manually. That makes it objectively worse than <i>Assembly.Load()</i> which at least gets the dependencies to load automatically.

MEF includes a whole ton of custom reflection code to make this work.

Ultimately, you cannot unload an assembly once it has been loaded. You need to unload the entire app domain, as described in this MSDN article.

<h2><a name="solution">Solution</a></h2>

Based on the following premises:

Creating an assembly proxy (or wrapper), derived from MarshalByRefObject, so that the CLR can marshal it by reference across AppDomain boundaries. Loading the assembly within this proxy. Performing the reflection inside this proxy and return the data you need. Creating a temporary AppDomain and instantiating the assembly proxy in this AppDomain (AppDomain.CreateInstanceFrom). Unloading the AppDomain as soon as you finished reflecting.

However, you have to keep in mind that reflection on the assembly loaded this way is only possible inside the proxy (the one derived from MarshalByRefObject). It is not possible to return any "reflection object" (anything defined in the System.Reflection namespace, such as Type, MethodInfo, etc.). Trying to access these from another AppDomain (the caller's domain) would result in exceptions.

<h2><a name="usage">Usage</a></h2>

  • Types called across AppDomain boundaries must inherit MarshalByRefObject.
  • Types called across AppDomain boundaries must be called via an interface.
  • The property LoaderOptimization must be set to LoaderOptimization.MultiDomainHost.
  • Construct a proxy manager that loads assemblies into AppDomains, performs queries, and unloads AppDomains.

<h2><a name="installation">Installation</a></h2>

This library can be installed using NuGet found here.

<h2><a name="license">License</a></h2>

The source code for the site is licensed under the MIT license, which you can find in the MIT-LICENSE.txt file.

All graphical assets are licensed under the Creative Commons Attribution 3.0 Unported License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5.2

  • .NETStandard 2.0

  • .NETStandard 2.1

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on AssemblyLoader:

Package Downloads
NDesk.Options.Core

A callback-based program option parser for C#.

AsyncTask

Asynchronous Task Extension Library

CSTypes

C# Types Argument Parser

BitField.Extensions

.NET Library For BitField & Enum Extensions

Ranges

Range indexing for strings.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.3 185 9/16/2024
1.2.1 157 4/9/2024
1.1.3 2,441 11/25/2018

Update target framework to include .NET 9.0.