Host startup hook
功能
在程序运行前加载特定的dll
配置环境变量
DOTNET_STARTUP_HOOKS=/path/to/StartupHook1.dll:/path/to/StartupHook2.dll
dll代码示例
internal class StartupHook
{
public static void Initialize()
{
AssemblyLoadContext.Default.Resolving += SharedHostPolicy.SharedAssemblyResolver.LoadAssemblyFromSharedLocation;
}
}
namespace SharedHostPolicy
{
class SharedAssemblyResolver
{
public static Assembly LoadAssemblyFromSharedLocation(AssemblyLoadContext context, AssemblyName assemblyName)
{
string sharedAssemblyPath = ""; // find assemblyName in shared location...
if (sharedAssemblyPath != null)
return AssemblyLoadContext.Default.LoadFromAssemblyPath(sharedAssemblyPath);
return null;
}
}
}
留待后查,同时方便他人
联系我:renhanlinbsl@163.com
联系我:renhanlinbsl@163.com