在使用VS AllJoyn Studio生成的消费者代码中是否有人经历过System.IO.FileNotFoundException?VS AllJoyn Studio - 生成的消费者因System.IO.FileNotFoundException而失败
我想创建一个AllJoyn启用UWP应用程序使用VS AllJoyn Studio扩展。通过提供的工具,我能够生成AllJoyn样板代码库,用于从我的示例introspection xml中创建生产者和消费者。我能够创建生产者UWP,将其部署到运行Windows 10 Iot Core的RPi 3设备并使用Iot Explorer连接到它。使用AllJoyn资源管理器,我可以更改在网络上运行的生产者的状态。当我从AllJoyn资源管理器执行SetDesireTemperature方法时,我获得了成功,并且更改反映在接口上的DesiredTemperature属性上。 PS - 这是我的第一个AllJoyn应用程序。
这里是我的消费者的代码抛出一个异常就此致电试图实例消费者:
_消费=等待TemperatureConsumer.FromIdAsync(args.Id);
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
private TemperatureConsumer _consumer;
private DeviceWatcher _deviceWatcher;
public MainPage()
{
this.InitializeComponent();
_deviceWatcher = AllJoynBusAttachment.GetWatcher(new List<string> { TemperatureConsumer.InterfaceName });
_deviceWatcher.Added += Watcher_Added;
_deviceWatcher.Start();
}
private async void _deviceWatcher_Added(DeviceWatcher sender, DeviceInformation args)
{
// throws System.IO.FileNotFoundException;
_consumer = await TemperatureConsumer.FromIdAsync(args.Id);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
_deviceWatcher = AllJoynBusAttachment.GetWatcher(new List<string>() { TemperatureConsumer.InterfaceName });
_deviceWatcher.Added += _deviceWatcher_Added;
_deviceWatcher.Start();
}
}
这里是我的制片代码工作:
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page, ITemperatureService
{
private AllJoynBusAttachment _allJoynBusAttachment;
private TemperatureProducer _temperatureProducer;
private double _temperature;
public double Temperature
{
get { return _temperature; }
set
{
_temperatureProducer?.EmitDesiredTemperatureChanged();
_temperature = value;
}
}
public MainPage()
{
this.InitializeComponent();
_allJoynBusAttachment = new AllJoynBusAttachment();
_allJoynBusAttachment.StateChanged += _allJoynBusAttachment_StateChanged;
_allJoynBusAttachment.CredentialsRequested += _allJoynBusAttachment_CredentialsRequested;
_temperatureProducer = new TemperatureProducer(_allJoynBusAttachment);
_temperatureProducer.Service = this;
_temperatureProducer.Start();
}
public IAsyncOperation<TemperatureGetDesiredTemperatureResult> GetDesiredTemperatureAsync(AllJoynMessageInfo info)
{
return Task.Factory.StartNew(() => TemperatureGetDesiredTemperatureResult.CreateSuccessResult(Temperature)).AsAsyncOperation();
}
public IAsyncOperation<TemperatureSetDesireTemperatureResult> SetDesireTemperatureAsync(AllJoynMessageInfo info, double interfaceMemberDesiredValue)
{
return Task.Factory.StartNew(() =>
{
Temperature = interfaceMemberDesiredValue;
return TemperatureSetDesireTemperatureResult.CreateSuccessResult();
}).AsAsyncOperation();
}
private void _allJoynBusAttachment_CredentialsRequested(AllJoynBusAttachment sender, AllJoynCredentialsRequestedEventArgs args)
{
// throw new NotImplementedException();
}
private void _allJoynBusAttachment_StateChanged(AllJoynBusAttachment sender, AllJoynBusAttachmentStateChangedEventArgs args)
{
// throw new NotImplementedException();
}
}
自省XML:
<?xml version="1.0" encoding="utf-8"?>
<node>
<interface name="com.inlynk.Sensor.Temperature">
<method name="SetDesireTemperature">
<annotation name="org.alljoyn.Bus.Secure" value="true" />
<arg name="desiredValue" type="d" direction="in"></arg>
</method>
<property name="DesiredTemperature" type="d" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property>
</interface>
</node>