引发异常:Microsoft.Azure.Devices.Client.dll

时间:2018-12-08 10:55:24

标签: c# azure raspberry-pi3 azure-iot-hub

  
     

用例:

     

我制作了一个简单的UWP后台应用程序,以从连接的Raspberry-PI3中检索温度传感器数据,并将LED传感器设置为蓝色或   红色闪烁,具体取决于MAX_TEMP的值。>
  PI3在Windows 10 IoT核心版(OS 10.0.17763107)上运行   UWP在启动时运行一个后台任务,该任务按时间间隔读取附加温度传感器上的值。   PI3并根据需要设置PI3上连接的LED传感器   (取决于读取的温度值是否不超过MAX_TEMP   值,如果当前温度值超过MAX_VALUE,则   消息被发送到云上的IoTHub连接设备,一些代码   抢断:

//读取附带的温度传感器的值并将其转换为字符串

var sensorValue = _temperatureSensor.TemperatureInCelsius().ToString();

if (Double.Parse(sensorValue) > MAX_TEMP)
{
   // When MAX_TEMP exceeds, red led on, blue led off
   _ledRed.ChangeState(SensorStatus.On);
   _ledBlue.ChangeState(SensorStatus.Off);

   // Create event message to send to Azure IoT Hub ...
   var telemetryDataPoint = new
   {
      messageId = _messageId++,
      message = $"Max Allowed temperature exceeded !",
      deviceId = _deviceId,
      maxTemp = $"{MAX_TEMP}",
      temperature = sensorValue,
      ledRedState = $"{_ledRed.CurrentState}",
      ledBlueState = $"{_ledBlue.CurrentState}"
   };



// Create message to send to Cloud (IoTHub)
   var messageString = JsonConvert.SerializeObject(telemetryDataPoint);
   var message = new Microsoft.Azure.Devices.Client.Message     
   (System.Text.Encoding.ASCII.GetBytes(messageString));

   // Send to cloud ...
   **// This throws the exception as shown below !!!!!
   await _deviceClient.SendEventAsync(message).ConfigureAwait(false);**

}

Message thrown :
Exception thrown: 'System.MissingMethodException' in Microsoft.Azure.Devices.Client.dll
Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.ni.dll
Exception thrown: 'System.MissingMethodException' in System.Private.CoreLib.ni.dll
The thread 0xcd8 has exited with code 0 (0x0).

感谢任何回应!

K 伊曼纽尔·纽特斯(Emmanuel Nuyttens)

0 个答案:

没有答案