Luke.AssemblyHotLoad 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Luke.AssemblyHotLoad --version 1.0.1
                    
NuGet\Install-Package Luke.AssemblyHotLoad -Version 1.0.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="Luke.AssemblyHotLoad" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Luke.AssemblyHotLoad" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Luke.AssemblyHotLoad" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Luke.AssemblyHotLoad --version 1.0.1
                    
#r "nuget: Luke.AssemblyHotLoad, 1.0.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.
#:package Luke.AssemblyHotLoad@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Luke.AssemblyHotLoad&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Luke.AssemblyHotLoad&version=1.0.1
                    
Install as a Cake Tool

Luke.AssemblyHotLoad

A .Net Assembly Hotload Library

you can use this to Hotload your Library,and it will not occupy files

一个.Net平台下热加载库

你可以使用它热加载库,而且不会占用文件,可以用作插件

在dll文件新增或更新时会自动加载到内存

Using

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

    
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAssemblyLoadServices(configuration.GetSection("Test"));
        }

    
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.StartAssemblyLoad();
        }
    }


appsettings.json

{
  "Test": {
    "Path": "Plugins",
    "Filter": "Plugin.*.dll",
    "AutoDelete": false
  }
}

Path: 加载路径 可以是绝对路径或相对路径

Filter:文件匹配过滤 Plugin.*.dll 匹配 Plugin.XXXX.dll

AutoDelete:在文件被删除时是否同时卸载程序集

Add a new Library Plugin.Abstractions

添加一个新类库 Plugin.Abstractions

Add a new interface IPluginCommand

添加一个新接口类 IPluginCommand

public interface IPluginCommand
    {

        void Hello(string message);

    }

Add a new Library Plugin.Test1

添加一个新类库 Plugin.Test1

Add a new class PluginCommand

添加一个新类 PluginCommand

public class PluginCommand : IPluginCommand
    {
        public void Hello(string message)
        {
            Console.WriteLine("Test:" +  message);
        }
	}

use

copy Plugin.Test1.dll to Path

Plugin.Test1.dll 复制到 Path 路径


[ApiController]
    [Route("[controller]")]
    public class WeatherForecastController : ControllerBase
    {

        private readonly ILogger<WeatherForecastController> _logger;

        private readonly IAssemblyLoadManager _assemblyLoadManager;

        public WeatherForecastController(ILogger<WeatherForecastController> logger, IAssemblyLoadManager assemblyLoadManager)
        {
            _logger = logger;
            _assemblyLoadManager = assemblyLoadManager;
        }

        [HttpGet]
        public void Get()
        {
            string assemblyName = "Plugin.Test1";
            string fullClassName = assemblyName + ".PluginCommand";
            Assembly assembly = _assemblyLoadManager.GetAssembly(assemblyName);
            IPluginCommand command = assembly.CreateInstance(fullClassName) as IPluginCommand;
            command.Hello("use PluginCommand Hello, but not Reference Plugin.Test1");
        }
    }
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 135 10/13/2024
1.0.2 258 4/5/2023
1.0.1 256 3/18/2023
1.0.0 275 3/18/2023