Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
AssemblyResolve handler for plugin third-party dependencies #521
I'm writing a plugin for neo-cli to publish smart contract events to a Redis PubSub queue. I quickly ran into a problem - since neo-cli plugins themselves are loaded at runtime, the existing .NET mechanism for resolving third-party dependencies in assemblies does not work (at least not for .Net Core), and the plugin fails to load with the following error:
This patch attempts to address this by adding an AssemblyResolve handler that is called when an assembly fails to load, and proceeds to attempt to resolve and load the dependencies of the plugin. (Note that the way the
After this patch is applied I no longer experience the above error and my plugin functions as expected.
In my research on this topic, I've also discovered that the approach I've taken may not be the ideal way to go about solving the problem - some other issues with runtime Assembly loading are noted on this page such as versioning issues/race conditions that might occur if multiple plugins attempt to use different versions of the same third-party library. This may not be a huge concern at present, so instead of incorporating this entire third-party class I implemented the more straightforward single-function solution.