Jump to content

Plugin Reference Plugin


rhodges

Recommended Posts

rhodges

Personal Plugin.

 

I do some stuff with nfo files. Before, I had a plugin that referenced and inherited classes from MediaBrowser.XbmcMetadata. Since that has gone away, I changed my references and code to NfoMetadata.

 

In the log, I see errors:

2019-01-17 10:32:23.208 Error App: LoaderException: Could not load file or assembly 'NfoMetadata, Version=1.0.10.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

 

That file does exist, in the plugins folder, but maybe my stuff is trying to do something too soon?

 

Is there a way around this?

 

Edit: I think I have an ugly hack that'll work.

 

Looking at the old 3.5.1 code on github, it seems that you load all types, including private/internal. It'll error on my class because it won't resolve the NfoMetadata and it is too early to hook into AppDomain.CurrentDomain.AssemblyResolve.

 

Because you still go ahead and load what you could resolve, I wrap a thin "wrapper class". This class just wraps around the one that "fails" to load. This class gets discovered and is available as a metadata provider/saver.

 

I am then able to, in my plugins main constructor, hook into the AppDomain.CurrentDomain.AssemblyResolve to resolve the reference needed. Since this class is instantiated after my plugins main constructor, the hook into AssemblyResolve works to satisfy the assembly reference.

        private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
        {
            var assemblyName = new AssemblyName(args.Name);
            var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == assemblyName.FullName);

            return assembly;
        }

I still have the errors in the log where it tries to load my internal class, the ones that inherits from NfoMetadata classes, but that isn't a show stopper.

 

It would be nice to see something like this, or something that looks at the plugin and loads them in reference order.

 

Cheers!

Edited by rhodges
Link to comment
Share on other sites

  • 3 weeks later...
rhodges

How did you add the nfo metadata reference to your project? 

Sorry for the delayed response. I was out of the country for a couple of weeks.

 

I made a reference to the NfoMetadata dll.

 

C:\Users\Developer\AppData\Roaming\Emby-Server\programdata\plugins\NfoMetadata.dll

 

My workaround works, its a little ugly, but I'll take ugly and working then pretty and not working. I'm not needing any changes now, just documenting what I did and mentioning all this because I could that as more functionality is pulled into plugins, this sort of thing might come up more in the future.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...