【问题标题】:VS AllJoyn Studio - Generated consumer failing with System.IO.FileNotFoundExceptionVS AllJoyn Studio - 生成的消费者因 System.IO.FileNotFoundException 而失败
【发布时间】:2017-02-28 11:43:10
【问题描述】:

有没有人在使用 VS AllJoyn Studio 生成的消费者代码中遇到 System.IO.FileNotFoundException?

我正在尝试使用 VS AllJoyn Studio 扩展创建启用 AllJoyn 的 UWP 应用程序。使用提供的工具,我能够生成 AllJoyn 样板代码库,用于从我的示例自省 xml 创建生产者和消费者。我能够创建生产者 UWP,将其部署到运行 Windows 10 物联网核心的 RPi 3 设备并使用物联网资源管理器连接到它。使用 AllJoyn Explorer,我可以更改网络上运行的生产者的状态。当我从 AllJoyn Explorer 执行 SetDesireTemperature 方法时,我获得了成功,并且更改反映在界面上的 DesiredTemperature 属性上。 PS - 这是我的第一个 AllJoyn 应用程序。

这是我的消费者代码,它在尝试实例化消费者的调用中抛出异常:

_consumer = 等待 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>

【问题讨论】:

    标签: c# consumer alljoyn


    【解决方案1】:

    所以,我找到了自己问题的答案。如果使用最新版本的 AllJoyn Studio,我所需要做的就是让我的消费者应用程序目标构建 14393。我是否同时更改了最小和最大目标,我是黄金。见here

    1. 右键单击项目
    2. 选择属性
    3. 在应用程序菜单屏幕上,将目标最小值和最大值设置为 14393

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-09
      • 2019-08-14
      • 1970-01-01
      • 2018-01-27
      • 2019-10-06
      相关资源
      最近更新 更多