The IOT hub client SDK version 1.0.22 requires an assembly binding redirect (this is added automatically when installing the SDK into a console app). However in functions that assembly binding redirect is not applied and it results in an error.
Steps to reproduce:
Create a function with this code and project.json:
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Client;
private const string DeviceConnectionString = "connection string”;
public static void Run(string input, TraceWriter log)
{
DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(DeviceConnectionString, TransportType.Http1);
if (deviceClient == null)
{
log.Info($"Failed to create DeviceClient!");
}
SendEvent(deviceClient,log).Wait();
log.Info($"C# End");
}
static async Task SendEvent(DeviceClient deviceClient, TraceWriter log)
{
string dataBuffer;
dataBuffer = "Hello world" + Guid.NewGuid().ToString();
Message eventMessage = new Message(Encoding.UTF8.GetBytes(dataBuffer));
log.Info($"C# Send message to the device");
await deviceClient.SendEventAsync(eventMessage);
}
Paste in an appropriate IOT hub connection string and attempt to run the code
Expected result: no assembly loading errors occur
Actual result: Exception while executing function: Functions.DevicesTest. mscorlib: Exception has been thrown by the target of an invocation. mscorlib: One or more errors occurred. Microsoft.Azure.Devices.Client: Could not load file or assembly 'Validation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7' or one of its dependencies. The system cannot find the file specified.
The IOT hub client SDK version 1.0.22 requires an assembly binding redirect (this is added automatically when installing the SDK into a console app). However in functions that assembly binding redirect is not applied and it results in an error.
Steps to reproduce:
Expected result: no assembly loading errors occur Actual result:
Exception while executing function: Functions.DevicesTest. mscorlib: Exception has been thrown by the target of an invocation. mscorlib: One or more errors occurred. Microsoft.Azure.Devices.Client: Could not load file or assembly 'Validation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7' or one of its dependencies. The system cannot find the file specified.