1

Has anyone experienced System.IO.FileNotFoundException in the consumer code generated using VS AllJoyn Studio?

I am trying to create an AllJoyn enabled UWP application using the VS AllJoyn Studio extension. With the provided tooling, I am able to generate the AllJoyn boilerplate code base for creating both the producer and consumer from my sample introspection xml. I am able to create the producer UWP, deploy it to a RPi 3 device running Windows 10 Iot Core and connect to it using the Iot Explorer. With the AllJoyn Explorer I am able to change the state of the producer running on the network. When I execute the SetDesireTemperature method from the AllJoyn Explorer I get a success and the changes are reflected on the DesiredTemperature property on the interface. PS - This is my first AllJoyn application.

Here is my consumer code which throws an exception on this call trying to instantiate the consumer:

_consumer = await 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();

    }
}

Here is my producer code which works:

/// <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();
    }
}

Introspection 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>
Kirk Kerr
  • 11
  • 1

1 Answers1

0

So, I found the answer to my own question. If using the latest version of AllJoyn Studio all I needed to do was to have my consumer app target build 14393. Was I changed both the min and max targets I was golden. See here

  1. Right Click the project
  2. Select properties
  3. On the Application menu screen set targeting min and max to 14393

Hope this helps.

Kirk Kerr
  • 11
  • 1