Connected Service for Azure IoT Hub Extension for Visual Studio currently not working for ARM projects (V 1.2.0) – Workaround

I am a frequent user of the great “Connected Service for Azure IoT Hub” Extension for Visual Studio to add support for sending messages to Azure IoT Hub to my IoT client projects.

image

I am using Visual Studio 2015 Enterprise with Update 2

image

Observation

In the latest build, the tool now defaults to using AMQP instead of HTTP as transport protocol and adds a slew of new NUGet references to the project.

The Output window of Visual Studio lists them as:

[4/27/2016 4:06:36.687 PM] Adding Azure IoT Hub to the project.
[4/27/2016 4:06:40.266 PM] Installing NuGet package ‘Newtonsoft.Json’ version 6.0.8.
[4/27/2016 4:06:40.333 PM] Installing NuGet package ‘Microsoft.Azure.Amqp’ version 1.1.1.
[4/27/2016 4:06:40.344 PM] Installing NuGet package ‘PCLCrypto’ version 2.0.147.
[4/27/2016 4:06:40.366 PM] Installing NuGet package ‘PInvoke.BCrypt’ version 0.3.2.
[4/27/2016 4:06:40.377 PM] Installing NuGet package ‘PInvoke.Kernel32’ version 0.3.2.
[4/27/2016 4:06:40.391 PM] Installing NuGet package ‘PInvoke.NCrypt’ version 0.3.2.
[4/27/2016 4:06:40.413 PM] Installing NuGet package ‘PInvoke.Windows.Core’ version 0.3.2.
[4/27/2016 4:06:40.432 PM] Installing NuGet package ‘Validation’ version 2.2.8.

[4/27/2016 4:06:49.846 PM] New service instance IoTMonitoring created
[4/27/2016 4:06:49.894 PM] Successfully added Azure IoT Hub to the project.

Problem 

Trying to compile the project yields the following errors:

Error        File C:\Users\xxx\Documents\Visual Studio 2015\Projects\Tests\Win10IoT Thermo IoTSuite %28Start%29\Win10IoT Thermo\obj\ARM\Debug\Validation\en\Validation.Strings.resw not found.    Win10IoT Thermo    C:\Users\xxx\Documents\Visual Studio 2015\Projects\Tests\Win10IoT Thermo IoTSuite (Start)\Win10IoT Thermo\MakePRI       

Error        Processing Resources failed with error: The system cannot find the file specified.    Win10IoT Thermo    C:\Users\xxx\Documents\Visual Studio 2015\Projects\Tests\Win10IoT Thermo IoTSuite (Start)\Win10IoT Thermo\MakePri       

Workaround

The workaround is to switch the protocol used to talk to IoT Hub from AMQP to HTTP by editing the generated “AzureIoTHub.cs” class:

From:

var deviceClient = DeviceClient.CreateFromConnectionString(deviceConnectionString, TransportType.Amqp);

To:

var deviceClient = DeviceClient.CreateFromConnectionString(deviceConnectionString, TransportType.Http1);

And remove all the references added by the Connected Service for Azure IoT Hub Extension except for Newtonsoft.Json:

Remove NuGet package ‘Microsoft.Azure.Amqp’ version 1.1.1.
Remove NuGet package ‘PCLCrypto’ version 2.0.147.
Remove NuGet package ‘PInvoke.BCrypt’ version 0.3.2.
Remove NuGet package ‘PInvoke.Kernel32’ version 0.3.2.
Remove NuGet package ‘PInvoke.NCrypt’ version 0.3.2.
Remove NuGet package ‘PInvoke.Windows.Core’ version 0.3.2.
Remove NuGet package ‘Validation’ version 2.2.8.

After these steps, the project compiles again and successfully sends messages (HTTP) to the Azure IoT Hub.

About TechPreacher

Technical Evangelist working for Microsoft Switzerland. Focusing on the Internet of Things and Windows development. EV geek and passionate gamer, with a life.
%d bloggers like this: