mickle026 401 Posted February 27, 2020 Share Posted February 27, 2020 Im trying to code a plugin in vb.net I can get the plugin to load but not sure how to get it to load the settings page. I have created the file Configuration\VirtualFolders.html and set the compiler to embed it as an embeded resource, but im at all sure how to load it as system reflection is used in a standard vb.net case. I have set the name .Name = "VirtualFolders" so that the web url is :8096/web/index.html#!/configurationpage?name=VirtualFolders the embeded resource as .EmbeddedResourcePath = [GetType]().[Namespace] & ".Configuration.VirtualFolders.html" The plugin is showing in plugins and has the uninstall and settings options but the page isn't loading Any ideas what I am either doing wrong or not doing? Imports MediaBrowser.Common.Configuration Imports MediaBrowser.Common.Plugins Imports MediaBrowser.Model.Plugins Imports MediaBrowser.Model.Serialization Imports MediaBrowser.Plugins.VirtualFolders.VF.Configuration Namespace MediaBrowser.Plugins.VirtualFolders Public Class Plugin : Inherits BasePlugin(Of PluginConfiguration) : Implements IHasWebPages Public Shared Property Instance As Plugin Public Sub New(ByVal applicationPaths As IApplicationPaths, ByVal xmlSerializer As IXmlSerializer) MyBase.New(applicationPaths, xmlSerializer) Instance = Me End Sub Public Function GetPages() As IEnumerable(Of PluginPageInfo) Implements IHasWebPages.GetPages Return {New PluginPageInfo With { .Name = "VirtualFolders", .EmbeddedResourcePath = [GetType]().[Namespace] & ".Configuration.VirtualFolders.html" }} End Function Link to comment Share on other sites More sharing options...
Luke 37098 Posted February 27, 2020 Share Posted February 27, 2020 Hi, there's lots of examples you can compare to. I would compare to the AutoOrganize plugin: https://github.com/MediaBrowser/Emby.AutoOrganize And then you should be able to find the difference between that and yours. Link to comment Share on other sites More sharing options...
mickle026 401 Posted February 28, 2020 Author Share Posted February 28, 2020 Hi, there's lots of examples you can compare to. I would compare to the AutoOrganize plugin: https://github.com/MediaBrowser/Emby.AutoOrganize And then you should be able to find the difference between that and yours. It might help with other queries I may have but didnt help with this, but its ok I have figured it out a working solution. I'll post it here incase others may want to do the same. I have to load the embeded resource differently and to help matters vb.net doesn't see the get type names the same as c# ie the namespace of the class in vb.net cannot be easily got the same as c#. .Configuration.virtualfolders.html was MediaBrowser.Plugins.VirtualFolders.virtualfolders.html in the vb.net compiler. The former being my Namespace name as in c# GetType().Namespace + File URL. VB.net expects a value in the brackets () GetType().Namespace for getting the executing assemblies namespace but there is no startup object GetType(<here>).. Otherwise its getting GetType(null). Dim t As String = [GetType]().Namespace returns "Virtual Folders" in my case and not MediaBrowser.Plugins.VirtualFolders. In VB Dim t As String = GetType().Namespace this returns MediaBrowser.Plugins.VirtualFolders.MediaBrowser.Plugins.VirtualFolders. I cannot find a working method in vb.net for actually getting the namespace of the executing class (assembly) as just "MediaBrowser.Plugins.VirtualFolders.", I have tried many differnet methods so far. So I either have to type it whole MediaBrowser.Plugins.VirtualFolders.virtualfolders.html or load the embeded resources into an array Dim res() As String = [GetType]().Assembly.GetManifestResourceNames() and then refer to the page as an array index ie, .EmbeddedResourcePath = res(0) If anyone has a better suggestion im all ears ... Spent way to long on this weird anomoly ..... Link to comment Share on other sites More sharing options...
Luke 37098 Posted February 28, 2020 Share Posted February 28, 2020 @@chef may have some tips. Link to comment Share on other sites More sharing options...
mickle026 401 Posted February 28, 2020 Author Share Posted February 28, 2020 (edited) Well here is the actual answer in vb.net : DO NOT USE THE NAMESPACE CONVENTION!! I had a little thought as I was making a coffee, as vb.net was compiling the namespace as this: MediaBrowser.Plugins.VirtualFolders.MediaBrowser.Plugins.VirtualFolders. then maybe its already assigned by the compiler and I am adding it again using the "Namespace MediaBrowser.Plugins.VirtualFolders" and "End Namespace" so I just tried remarking it out altogether. Did a compile and it works first time. It does seem to me , and it had never occured to me before when importing (imports) other files (using in c#) that this actually happens - one of those duh moments..... ' Namespace MediaBrowser.Plugins.VirtualFolders DO NOT USE NAMESPACE IN VB.NET, note also the .configuration is not needed in the embeded resource folder url Imports System.IO Imports System.Reflection Imports MediaBrowser.Common.Configuration Imports MediaBrowser.Common.Plugins Imports MediaBrowser.Model.Plugins Imports MediaBrowser.Model.Serialization Imports MediaBrowser.Plugins.VirtualFolders.VF.Configuration Public Class Plugin : Inherits BasePlugin(Of PluginConfiguration) : Implements IHasWebPages Public Shared Property Instance As Plugin Public Sub New(ByVal applicationPaths As IApplicationPaths, ByVal xmlSerializer As IXmlSerializer) MyBase.New(applicationPaths, xmlSerializer) Instance = Me End Sub Public Function GetPages() As IEnumerable(Of PluginPageInfo) Implements IHasWebPages.GetPages Dim t As String = [GetType]().Namespace Return {New PluginPageInfo With { .Name = t, .EmbeddedResourcePath = t & ".virtualfolders.html", .EnableInMainMenu = True}} End Function Private _id As Guid = New Guid("1F03EA4D-F6A7-43B2-A7A8-CC99E3EED70C") Public Overrides ReadOnly Property Id As Guid Get Return _id End Get End Property Public Overrides ReadOnly Property Name As String Get Return "VirtualFolders" End Get End Property Public Overrides ReadOnly Property Description As String Get Return "Create Virtual Media Folder Copies of Original Media." End Get End Property End Class In the example above the .Name is set to the namespace so that I can see what is being seen by the compiler in [GetType]().Namespace as an url in emby http://localhost:8096/web/index.html#!/configurationpage?name=MediaBrowser.Plugins.VirtualFolders I will change this .Name back to a readable name .Name="VirtualFolders", http://localhost:8096/web/index.html#!/configurationpage?name=VirtualFolders Edited February 28, 2020 by mickle026 Link to comment Share on other sites More sharing options...
chef 3746 Posted February 28, 2020 Share Posted February 28, 2020 1 Link to comment Share on other sites More sharing options...
mickle026 401 Posted March 4, 2020 Author Share Posted March 4, 2020 (edited) Yes I have a plugin outlined in visual basic from before. Let me dig it out. I'll be back. There are some a couple 'gotchas' when coding plugins. I will help guide you through it @@chef Did you get anywhere finding your vb code ? Thanks Edited March 4, 2020 by mickle026 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now