Search code examples
c#azurexamarinportable-class-libraryazure-mobile-services

Assembly version mismatch when performing unit-testing of Azure Mobile Services with PCL and Xamarin


Good day.

I want to create NUnit tests for my PCL xamarin library. There are 1.1.0 Azure Mobile Service in xamarin components right now and 1.1.1 in NuGet

As i understand i need MobileServices.Ext for each platform, so i need 1.1.0 version for windows. Am i right? Is so, where can i find it?

I tried to add Microsoft.WindowsAzure.Mobile from xamarin Component store (version 1.1.0 in store, file version 1.0.0) and Microsoft.WindowsAzure.Mobile.Ext from Nuget (version 1.1.0)

here is exception

System.TypeInitializationException : Инициализатор типа "RateIt.Backend.SAL.AzureWorker" выдал исключение. ----> System.IO.FileLoadException : Не удалось загрузить файл или сборку "Microsoft.WindowsAzure.Mobile.Ext, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" либо одну из их зависимостей. Найденное определение манифеста сборки не соответствует ссылке на сборку. (Исключение из HRESULT: 0x80131040)

unit tests project needs this: Microsoft.WindowsAzure.Mobile.Ext, Version=1.0.0.0

as @TheESJ adviced it tried to add bindings

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.Mobile.Ext" publicKeyToken="null" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

That doesn't help. Right now i found workaround: "linked project extension" with all files from PCL linked to project with tests, so i can use azure from NuGet and don't bother about PCL


Solution

  • Version 1.1.0 of the NuGet package and Xamarin component had some issues when used together. As of Version 1.1.5 this is no longer the case, you should find they work together seamlessly.

    Also, version 1.1.5 of the NuGet package supports Xamarin.iOS and Xamarin.Android targets, so if you are using Visual Studio only you can skip the component completely.

    For more information see this tutorial.