bakes82 90 Posted October 25, 2020 Share Posted October 25, 2020 Anything special to include 3rd party dlls? Link to comment Share on other sites More sharing options...
Luke 37113 Posted October 26, 2020 Share Posted October 26, 2020 Hi, I would suggest just embedding the source code instead. Link to comment Share on other sites More sharing options...
bakes82 90 Posted October 26, 2020 Author Share Posted October 26, 2020 1 hour ago, Luke said: Hi, I would suggest just embedding the source code instead. So you want me to de compile someone else's nuget and embed it lol ...... Link to comment Share on other sites More sharing options...
Luke 37113 Posted October 26, 2020 Share Posted October 26, 2020 Well they might have the source available somewhere. Anyhow, that's my response from the standpoint of what will work the most reliably across all possible platforms. If you really want to embed the dll, it is possible and others have found ways to do this and those discussions can be found in the community. @chef may have done it before. Link to comment Share on other sites More sharing options...
bakes82 90 Posted October 26, 2020 Author Share Posted October 26, 2020 Well I kind of assumed being able to use Netwonsoft.Json you know would be a no brainier....... Can we target 2.1 standard? That has the new JSON built in I believe. Link to comment Share on other sites More sharing options...
Luke 37113 Posted October 26, 2020 Share Posted October 26, 2020 To be in the plugin catalog no as that won't work on all platforms. But if it works for you for a private plugin then yes you can. Link to comment Share on other sites More sharing options...
bakes82 90 Posted October 26, 2020 Author Share Posted October 26, 2020 Well can I just slap the newtonsoft.json dll someplace so I can see if this code is working Link to comment Share on other sites More sharing options...
chef 3746 Posted October 26, 2020 Share Posted October 26, 2020 What part of Newtonsoft do you need to use that the IJsonSerializer interface doesn't have? I do have a trick for embedding dependency dlls, then coping them over using reflection. Link to comment Share on other sites More sharing options...
bakes82 90 Posted October 26, 2020 Author Share Posted October 26, 2020 I actually want to use the trakt.net library which also uses the newtonsoft.json, I can pull the trakt library into my code, but then all the JSON stuff from newton needs the readers/writers and thats a mess when you try to pull the other lib in to the code. Can you post the reflection. Link to comment Share on other sites More sharing options...
chef 3746 Posted October 26, 2020 Share Posted October 26, 2020 (edited) 55 minutes ago, bakes82 said: I actually want to use the trakt.net library which also uses the newtonsoft.json, I can pull the trakt library into my code, but then all the JSON stuff from newton needs the readers/writers and thats a mess when you try to pull the other lib in to the code. Can you post the reflection. @Luke does emby still use Newtonsoft as it's serializer library, or did you guys decide to use something else? @bakes82 if emby uses Newtonsoft as it's base json serializer, you can figure out which version it's using, then you can add that version dependency to your plugin project solution and call it directly. When you load the plugin, it will match the version emby uses and use it. But, this will only work if emby still uses Newtonsoft as one of its own project dependencies. Only other thing to keep in mind, is to find a version of the trakt.net library that uses the same Newtonsoft version. If they don't match you'll get runtime errors. If you swap out versions of Newtonsoft, emby may have runtime errors. Is there a way to get the trakt.net c# binaries and load the entire project into your plugin? Edited October 26, 2020 by chef Link to comment Share on other sites More sharing options...
bakes82 90 Posted October 26, 2020 Author Share Posted October 26, 2020 9 minutes ago, chef said: @Luke does emby still use Newtonsoft as it's serializer library, or did you decide to use something else? @bakes82 if emby uses Newtonsoft as it's base json serializer, you can figure out which version it's using, then you can add that version dependency to your plugin project solution and call it directly. When you load the plugin, it will match the version emby uses and use it. But, this will only work if emby still uses Newtonsoft as one of its own project dependencies. So what about the code for the reflection? There any many nugets that are premade for lots of things lol. Seems way easier for me to be able to inject the DLL some how so I dont need to pull their repo copy out the code etc. Even if there was a folder that we could put custom DLL in and emby would load from it would be fine too. Link to comment Share on other sites More sharing options...
chef 3746 Posted October 26, 2020 Share Posted October 26, 2020 An exame of utilizing emby dependencies directly is In my unzip and copy plugin, I call functions directly from SharpCompress.dll which emby uses to update itself. That particular library can also be used to unzip .rar files and copy them around. That plugin skips the IZip interface emby offers and uses the library binaries directly. Link to comment Share on other sites More sharing options...
chef 3746 Posted October 26, 2020 Share Posted October 26, 2020 Okay I can post reflection code here one moment. Link to comment Share on other sites More sharing options...
chef 3746 Posted October 26, 2020 Share Posted October 26, 2020 (edited) this gets a bit hacky, so bare with me Save the DLL as an embeded resource in your solution. So you will have a dependency on it, as well as the physical DLL in your solution. Next we have to find the file in your solution so we can copy it over to the Emby Application system folder. Something like this: private static void WriteResourceToFile(string resourceName, string fileFullPath) { // This should locate the first resource in your solution with the "resourceName" using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream().Single(s => s.EndsWith(resourceName)) { using (var file = new FileStream(fileFullPath, FileMode.Create, FileAccess.Write)) { resource?.CopyTo(file); } } } "resourceName" is the library DLL "fileFullPath" is the full path to copy it to. In order to get the "fileFullPath" you can try something like this using the "IServerApplicationPaths" interface in Emby: private IServerApplicationPaths ServerApplicationPaths { get; set; } // This Run function should be in an class which inherits IServerEntryPoint so it runs when the server starts public void Run() { var rootFolderPath = ServerApplicationPaths.RootFolderPath; var serverSystemFolder = rootFolderPath.Replace(@"programdata\root", "system"); //Copy the binaries to the serverSystemFolder WriteResourceToFile("trakt", serverSystemFolder); } Now, you'll have to restart the server in order to load that binary which was copied over. Note: The above code is untested, it would probabaly be very close to that. Workflow would be: 1. Write the plugin and copy it into the "programdata/plugins" folder 2. Restart server to load plugin - which will copy over the binary into the server "system" folder 3. Restart server again to load new binary Caviots to watch out for: 1. You'll have to check to make sure the copied DLL doesn't exist already in the server "system" folder before copying it over (so it doesn't copy it every time the server starts). 2. Each time Emby updates it will remove your DLL from the server root, your plugin will have to replace it, if it doesn't exist, and restart the server again each time. It's hacky... I'm sorry it isn't less complicated. I would try copying the trakt.dll a couple times during testing, to make sure you have targeted the Emby "system" folder (which is the "Emby-Server/system" folder). Edited October 26, 2020 by chef Link to comment Share on other sites More sharing options...
BillOatman 502 Posted January 22, 2022 Share Posted January 22, 2022 (edited) Ugh I just ran into this trying to use a couple nugets. Forgot Emby was on netstandard 2. Jellyfin got lucky/smart and reworked with .NET5. So their plugins can use nuget packages. @Luke Is moving to .NET6 (probably now) on the roadmap at all? Edited January 22, 2022 by BillOatman Link to comment Share on other sites More sharing options...
Luke 37113 Posted January 23, 2022 Share Posted January 23, 2022 7 hours ago, BillOatman said: @Luke Is moving to .NET6 (probably now) on the roadmap at all? The beta server has done this, yes. 1 Link to comment Share on other sites More sharing options...
BillOatman 502 Posted January 23, 2022 Share Posted January 23, 2022 11 hours ago, Luke said: The beta server has done this, yes. Great news!!!!! 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