Jump to content

Cloning a plugin - What am I doing wrong?


BillOatman

Recommended Posts

BillOatman

I am creating a clone of the Huecontrol plugin to play with it.  In the source, I changed the name of the DLL, changed the name element in the code, and created a new GUID in the code.

If I go into settings for the plugin using the original plugins GUID everything is fine.  However with a new GUID it hangs with this in the log:

    *** Error Report ***
    Version: 4.1.1.0
    Command line: C:\Users\woatm\AppData\Roaming\Emby-Server\system\EmbyServer.dll
    Operating system: Microsoft Windows NT 6.2.9200.0
    64-Bit OS: True
    64-Bit Process: True
    User Interactive: True
    Runtime: file:///C:/Users/woatm/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll
    Processor count: 12
    Program data path: C:\Users\woatm\AppData\Roaming\Emby-Server\programdata
    Application directory: C:\Users\woatm\AppData\Roaming\Emby-Server\system
    System.InvalidOperationException: System.InvalidOperationException: Sequence contains no matching element
     at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
     at MediaBrowser.Api.PluginService.Get(GetPluginConfiguration request)
     at Emby.Server.Implementations.Services.ServiceExecGeneral.Execute(Type serviceType, IRequest request, Object instance, Object requestDto, String requestName)
     at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req)
     at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, ILogger logger, String operationName, CancellationToken cancellationToken)
     at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, String urlString, String host, String localPath, CancellationToken cancellationToken)
    Source: System.Linq
    TargetSite: TSource First[TSource](System.Collections.Generic.IEnumerable`1[TSource], System.Func`2[TSource,System.Boolean])

"Sequence contains no matching element" I assume is because of my new GUID.  So what do I need to do to get this clone to run?

Edited by BillOatman
Link to comment
Share on other sites

BillOatman

I made a copy of the huecontrol plugin and named it huecontrol2.

I gave it the new name in the plugin.cs, and also a new GUID.

When I went into settings of huecontrol2 it crashed with the error above.

I took the GUID from huecontrol and put it in plugin.cs for huecontrol2.

I went into the settings page again and that time it worked.

 

The act of using a different GUID caused the crash.

 

How are you supposed to assign a guid to a new plugin?  Is there something you have to do in Emby?

Link to comment
Share on other sites

chef

Make sure that you have the following:

 

1.The proper nuget package for Server.Core installed. Use the version 4.0.0.2 (don't use the newest release... It's for beta server)

 

2. It's not as simple as creating a different guid in The plugin class. The plugin configuration javascript also has a reference to the GUID so you'd have to look through the code and change it there as well.

 

I have never seen the hue plugin but if it follows the plugin guidlines, then there is a variable in The JavaScript called "pluginId".

Edited by chef
Link to comment
Share on other sites

I made a copy of the huecontrol plugin and named it huecontrol2.

I gave it the new name in the plugin.cs, and also a new GUID.

When I went into settings of huecontrol2 it crashed with the error above.

I took the GUID from huecontrol and put it in plugin.cs for huecontrol2.

I went into the settings page again and that time it worked.

 

The act of using a different GUID caused the crash.

 

How are you supposed to assign a guid to a new plugin?  Is there something you have to do in Emby?

 

It's in the plugin.cs file. that's the only place.

Link to comment
Share on other sites

chef

Then it sounds like he hasn't filled out the properties for the IHasWebPages interface properly.

 

Make sure the "GetPages" function is returning the proper configuration EmbeddedResourcePath.

 

And while you're at it, make sure any html document and JavaScript documents referenced in that function are set as Embedded Resource.

Edited by chef
Link to comment
Share on other sites

BillOatman

Thanks @@chef.  That all seems correct.  Plus like I said, if I use a guid that has not been used in my server before it fails, if I use a guid that has been used in another plugin, it works.

I'll play around some more and maybe try running the server as admin (this is on windows), maybe it can't create whatever key it needs for the settings or something,

Link to comment
Share on other sites

BillOatman

Actually I think I just stumbled on it.  The guid was also referenced in the config html file.  I'll try it later, But I suspect that's causing it

 

EDIT: Yeah that was it.  Thanks for the help. It is that way in the webhooks plugin as well so it's probably the standard.

Edited by BillOatman
Link to comment
Share on other sites

chef

Actually I think I just stumbled on it. The guid was also referenced in the config html file. I'll try it later, But I suspect that's causing it

 

EDIT: Yeah that was it. Thanks for the help. It is that way in the webhooks plugin as well so it's probably the standard.

 

2. It's not as simple as creating a different guid in The plugin class. The plugin configuration javascript also has a reference to the GUID so you'd have to look through the code and change it there as well.

 

I have never seen the hue plugin but if it follows the plugin guidlines, then there is a variable in The JavaScript called "pluginId".

Yep ;)

 

Glad it works for you.

Edited by chef
  • Like 1
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...