Jump to content

ApiInteraction Client assembly mismatch


Armand

Recommended Posts

Armand
Minor annoyance
 
Can we make sure the all projects in the api interaction solution are rebuild and checked before the new apiclient package is pushed ? 
Lately i've been running into the following error after updating my third part solution (in my case the mediaportal plugin) through nuget:

Exception: System.IO.FileLoadException: Could not load file or assembly 'MediaBrowser.Model, Version=3.0.4977.21657, Culture=neutral, PublicKeyToken=6cde51960597a7f9' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'MediaBrowser.Model, Version=3.0.4977.21657, Culture=neutral, PublicKeyToken=6cde51960597a7f9'
   at MediaBrowser.ApiInteraction.net35.ApiClient..ctor(String serverHostName, Int32 serverApiPort, String clientName, String deviceName, String deviceId, String applicationVersion)
 

 

 

In this case the net35 ApiClient expects and older version of the model assembly and throws an exception. Which means i have to update/rebuild the net35 project and wait for the next nuget release (or locally work around it). Maybe we can automate the nuget packaging so it will do this for all 3 projects before it is published ?

 

Link to comment
Share on other sites

Armand,

I'm not exactly sure where the issue is. I just went through the process of putting together version 182 of the common package - it has an updated 3.5 model. 

 

Then I updated the package in the ApiClient solution, and it has successfully updated the 3.5 version to 182.

Link to comment
Share on other sites

Armand

The new nuget package seems to work correctly. Like i explained earlier he issue only arrises in third party solutions (like mine) that have a reference to the nuget API Interaction package.

If you update and push the common package without rebuilding the API one it will throw an exception because it expects an older version of say the model library.

Perhaps there is a way around this but my previous attempts to solve this failed :)

Link to comment
Share on other sites

  • 1 month later...
Armand

and it happened again...

 

While it is still annoying i found a way to work around it through my code. If anybody is interested.

Alternative is rebinding in the *.config but i can't do that in my case.

// somewhere logical
const string MediaBrowserModelAssemblyVersion = "3.0.5021.27473";
const string MediaBrowserModelAssembly = "MediaBrowser.Model, Version=" + MediaBrowserModelAssemblyVersion + ", Culture=neutral, PublicKeyToken=6cde51960597a7f9";

// somewhere before the first media browser assemblies are being resolved.
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

// somewhere logical
private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            // this is a work around to load the expected assembly
            var requestedName = new AssemblyName(args.Name);
            if (requestedName.Name == "MediaBrowser.Model" && requestedName.Version.ToString() != MediaBrowserModelAssemblyVersion)
            {
                return Assembly.Load(MediaBrowserModelAssembly);
            }
            else
            {
                return null;
            }
        }
Link to comment
Share on other sites

This is because we pushed the model without pushing apiclient? If so that's my fault. I've been making sure to do both at the same time, but sometimes I forget. I'm about to push all of them and that will square it away.

Link to comment
Share on other sites

Done. Anytime that happens just shout in here and I'll fix it pronto. I'll also try to make sure it doesn't happen in the first place.

 

Also, I know you're very good with WPF so I guess I'll just re-extend the offer about working with me on MBT if you'd like to  :)

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...