Oakcool
Oakcool

Reputation: 1496

Why the error when instantiating Azure Mobile Services?

Here is the environment:

When I attempt to run the test project in debug I get the following error message:

A Windows Azure Mobile Services assembly for the current platform was not found. Ensure that the current project references both Microsoft.WindowsAzure.Mobile and the following platform-specific assembly: Microsoft.WindowsAzure.Mobile.Ext.

It happens on the following line:

private IMobileServiceClient _mobileService = new MobileServiceClient(
        "TheUrl",
        "TheKey"
        );

Since I have the package installed on both projects (Main Library, Test Proj), I cannot understand what I have to do with the error message, any light?

Upvotes: 3

Views: 1139

Answers (3)

James Q Quick
James Q Quick

Reputation: 455

Make sure that you are calling the CurrentPlatform.Init() function in your AppDelegate. IOS appears to be the only platform that needs that specific call to work. Additionally, I've gotten errors with multiple assembly references with System.RunTime, System.Threading, etc. where I need to get rid of those references to avoid ambiguity.

Upvotes: 0

3-putt
3-putt

Reputation: 239

Yeah, this one took me a bit of time to find but it was in the most obvious place at: https://components.xamarin.com/view/azure-mobile-services/

This guy nailed it too: http://blog.csainty.com/2013/12/quick-tip-azure-mobile-services-xamarin.html

  • When running on iOS, if you encounter a Windows Azure Mobile Services assembly for the current platform was not found error, make sure you call Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); in your iOS application.

  • If you encounter a CryptographicException using this component in Xamarin.Android projects, note that this only occurs when break on all errors or the equivalent in Xamarin Studio is turned on. The exception occurs within the mono HTTPS infrastructure and is automatically caught and handled and will not impact your application.

Upvotes: 3

Ashley Jackson
Ashley Jackson

Reputation: 313

In your test project you should be creating a Mock of the IMobileServiceClient and then setting your expected actions on the Mock. Try looking at Rhino Mock to see how to Mock Interfaces for testing

    private IMobileServiceClient client = MockRepository.GenerateMock();

Upvotes: 0

Related Questions