-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Setting up binding redirects #2
Comments
The plug-in architecture does not (and can not) allow a plugin-in specific binding redirect because that mechanism is handled by the .Net Framework and the config file it uses is based on the executable that initiates the process. Since plugins run in the same process as Paratext, they can't have their own binding redirects. |
@tombogle Thank you for the explanation. I was able to work around my issue by utilizing the code below: public override void OnAddedToParent(IPluginChildWindow parent, IWindowPluginHost host, string state)
{
var currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += FailedAssemblyResolutionHandler;
try
{
... code which causes the bind error
}
finally
{
currentDomain.AssemblyResolve -= FailedAssemblyResolutionHandler;
}
} private Assembly FailedAssemblyResolutionHandler(object sender, ResolveEventArgs args)
{
// Get just the name of assembly without version and other metadata
var truncatedName = new Regex(",.*").Replace(args.Name, string.Empty);
// Load the most up to date version
var assembly = Assembly.Load(truncatedName);
return assembly;
} Hopefully this information will be useful for others who may suffer from the same issue. |
I wonder if this might cause issues for Paratext (or for your plugin, or for another plugin)? See this article for a description of the potential problem and information about how to check if you are introducing a likely problem. If the DLLs are both strong-named, then I think this won't be a problem, but if that is the case, I would think that Paratext should not have thrown an exception. |
The AssemblyResolve event is raise for Microsoft.Owin 2.0.2.0, which should be strongly named. The version referenced in the plugin project is 4.2.1.0. When I debugged the code, this was the only assembly triggering the AssemblyResolve event. I can share a project which repro's the issue, if that would be helpful. |
@gerfen, I think a project that demonstrates the problem would be helpful. |
I finally had a chance to put together a repro project. I created this fork: https://github.com/gerfen/paratext_demo_plugins. I added three new projects and a new solution Projects
Solution
After building the ParatextDemoPlugins solution and activating the WebApiPlugin via Paratext, you can run the unit tests via the WebApiUnitTests solution. Both tests expect Paratext to be running with the WebApiPlugin activated.
Please note that this test will always fail when the timeout for the test fires but you should see output similar to this:
In the
Please let me know if I can provide any more details. Thank you for looking into this issue! |
@gerfen |
@gerfen I got your copy of the plugin demos and it seems to be working after I made one correction to your test code (I'm using VS 2019 and it didn't like the new way namespaces can be done) and one correction to the Paratext.exe.config file that wasn't allowing the newer version of the embedded plugin DLL to load (I'll make a correction to the Paratext). I have an update of the plugin interface in progress and committed a change to the demos to use the updated plugin API version (2.0.17, which isn't release yet). I probably should have done this change on a branch and merged it when the API work is complete (still learning about plugin code). Are you only getting the error when the FailedAssemblyResolutionHandler isn't used? |
@jwickberg Thanks for looking into my issue. Without the FailedAssemblyResolutionHandler or adding binding redirects to the Paratext.exe.config file, I cannot get the plug-in to work. |
I'm building a Paratext plug-in and I'm having issues with loading the correct assembly due to conflicting nuget packages. I can see from fuslogvw, that that a certain assembly is not being loaded. I am able to fix the issue by adding the binding redirect to the Paratext.exe.config file.
My question is this... Does the plug-in architecture allow me to specify a binding redirect in a plug-in specific assembly config file? Or is the Paratext.exe.config my only opportunity to resolve binding conflicts?
Thanks!
The text was updated successfully, but these errors were encountered: