Plugin error message jiwa.  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Re: Plugin error message jiwa.

Postby JuiceyBrucey » Wed Sep 13, 2023 9:33 am

Still getting the error message when enabling and saving the ToDo plugin.
I have followed all instructions.
I am lodging a ticket. It has taken way too much time already.
Thank you.
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Plugin error message jiwa.

Postby JuiceyBrucey » Wed Sep 20, 2023 9:14 am

Hi, as you are probably aware, I got support from JIWA by lodging a ticket and they have logged in and loaded the plugins correctly.
Many thanks to them for doing that.
I am still getting an error though. This is the error I am getting when doing a ToDo notification insert.
'ResponseStatus' =>
array (
'ErrorCode' => 'FileNotFoundException',
'Message' => 'Could not load file or assembly \'REST API, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\' or one of its dependencies. The system cannot find the file specified.',
'Errors' =>

I can see what the problem is, but I am not so sure the correct way to fix it. On the server the REST API plugins full name is "Plugin REST API", but the assembly reference is looking for "REST API".
I have had a bit of a poke around in there, but I dont want to change anything as it was loaded by your guys themselves.
Happy to fix it myself so that I learn how to do that, but will need some instruction on how to do it.
Thank you.
Cheers
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Plugin error message jiwa.  Topic is solved

Postby Mike.Sheen » Wed Sep 20, 2023 11:27 am

Add this method to your plugin class which implements IJiwaRESTAPIPlugin:

Code: Select all
public System.Reflection.Assembly AssemblyResolve(object sender, System.ResolveEventArgs args, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   // If the requested assembly is a reference to another plugin, then we need to attempt to resolve the assembly ourselves               
   foreach(JiwaFinancials.Jiwa.JiwaApplication.Plugin.PluginReference pluginReference in Plugin.PluginReferenceCollection)
   {
      if (String.Format("{0}, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", pluginReference.Name) == args.Name)
      {
         return System.Reflection.Assembly.LoadFile(pluginReference.Plugin.RuntimeFileName);
      }
   }
   
   return null;
}


and then in your Configure method of your class which implements IJiwaRESTAPIPlugin add this:
Code: Select all
// necessary or you may get the error "Could not load file or assembly 'REST API, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
// when invoking the route(s)
// need to read the reference collection as we don't read that unless compiling, and in this case we need to read it on logon whether it's compiled or not
Plugin.PluginReferenceCollection.Read();
// If we weren't referencing anything defined in the REST API plugin, then we wouldn't need to handle the AssemblyResolve event
AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, System.ResolveEventArgs args) { return AssemblyResolve(sender, args, Plugin); };


The problem isn't to do with the name of the plugin. It's related to your plugin referencing the REST API plugin and not being able to find it's assembly at runtime. The code above will add a custom assembly resolver to probe for any referenced assemblies in the location we would have written the .dll to when compiled.

This error will not always occur, sometimes you won't get the error if the assembly has already been loaded into the appdomain, so it largely depends on the order the plugins are loaded - but the above code works around that.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Plugin error message jiwa.

Postby JuiceyBrucey » Wed Sep 20, 2023 6:32 pm

yep, that fixed it.
ToDo note is inserted and popup reminder popped up as well.
Excellent.
Thank you very much.
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Previous

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 35 guests