Luke.AssemblyHotLoad
1.0.1
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
<PackageReference Include="Luke.AssemblyHotLoad" Version="1.0.1" />
<PackageVersion Include="Luke.AssemblyHotLoad" Version="1.0.1" />
<PackageReference Include="Luke.AssemblyHotLoad" />
paket add Luke.AssemblyHotLoad --version 1.0.1
#r "nuget: Luke.AssemblyHotLoad, 1.0.1"
#:package Luke.AssemblyHotLoad@1.0.1
#addin nuget:?package=Luke.AssemblyHotLoad&version=1.0.1
#tool nuget:?package=Luke.AssemblyHotLoad&version=1.0.1
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 | Versions 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. |
-
net5.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 5.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 5.0.0)
-
net6.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 6.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.