Jump to content


Photo

Cloning a plugin - What am I doing wrong?


  • Please log in to reply
8 replies to this topic

#1 BillOatman OFFLINE  

BillOatman

    Advanced Member

  • Members
  • 273 posts
  • Local time: 09:26 PM

Posted 18 May 2019 - 05:55 PM

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, 18 May 2019 - 06:00 PM.


#2 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 129303 posts
  • Local time: 09:26 PM

Posted 18 May 2019 - 06:03 PM

original plugins GUID? what is that?



#3 BillOatman OFFLINE  

BillOatman

    Advanced Member

  • Members
  • 273 posts
  • Local time: 09:26 PM

Posted 18 May 2019 - 08:49 PM

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?



#4 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3786 posts
  • Local time: 09:26 PM
  • LocationPeterborough, Canada

Posted 18 May 2019 - 09:29 PM

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, 18 May 2019 - 09:36 PM.


#5 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 129303 posts
  • Local time: 09:26 PM

Posted 18 May 2019 - 09:40 PM

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.



#6 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3786 posts
  • Local time: 09:26 PM
  • LocationPeterborough, Canada

Posted 18 May 2019 - 09:54 PM

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, 18 May 2019 - 09:57 PM.


#7 BillOatman OFFLINE  

BillOatman

    Advanced Member

  • Members
  • 273 posts
  • Local time: 09:26 PM

Posted 19 May 2019 - 10:09 AM

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,



#8 BillOatman OFFLINE  

BillOatman

    Advanced Member

  • Members
  • 273 posts
  • Local time: 09:26 PM

Posted 19 May 2019 - 10:18 AM

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, 19 May 2019 - 12:28 PM.


#9 chef OFFLINE  

chef

    Advanced Member

  • Developers
  • 3786 posts
  • Local time: 09:26 PM
  • LocationPeterborough, Canada

Posted 19 May 2019 - 02:13 PM

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, 19 May 2019 - 02:16 PM.

  • BillOatman likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users