Comments on: Plugin Architecture Pattern in C# https://code-maze.com/csharp-plugin-architecture-pattern/ Learn. Code. Succeed. Tue, 25 Jun 2024 07:33:22 +0000 hourly 1 https://wordpress.org/?v=6.7.5 By: Marinko Spasojević https://code-maze.com/csharp-plugin-architecture-pattern/#comment-11072 Tue, 25 Jun 2024 07:33:22 +0000 https://code-maze.com/?p=104016#comment-11072 In reply to Riccardo.

Hi Riccardo. That’s why we have the source code – so we don’t have to put every single code line inside the article. Readers can always download the code and use it to follow the article.

]]>
By: Riccardo https://code-maze.com/csharp-plugin-architecture-pattern/#comment-11071 Tue, 25 Jun 2024 07:26:22 +0000 https://code-maze.com/?p=104016#comment-11071 The implementation shown here for the PluginLoadContext class is missing the Load method overrides. From your own github repository:

public class PluginLoadContext : AssemblyLoadContext
{
private readonly AssemblyDependencyResolver _resolver;

public PluginLoadContext(string pluginPath)
{
_resolver = new AssemblyDependencyResolver(pluginPath);
}

protected override Assembly? Load(AssemblyName assemblyName)
{
var assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName);
if (assemblyPath != null)
{
return LoadFromAssemblyPath(assemblyPath);
}

return null;
}

protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
{
var libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName);
if (libraryPath != null)
{
return LoadUnmanagedDllFromPath(libraryPath);
}

return IntPtr.Zero;
}
}

]]>