2017-02-27 24 views
1

在使用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> 

回答

0

於是,我找到了答案,以我自己的問題。如果使用AllJoyn Studio的最新版本,我所需要做的就是讓我的消費者應用程序目標構建爲14393.我是否改變了最小和最大目標,我都是金手指。見here

  1. 右鍵單擊該項目
  2. 選擇性能
  3. 在應用程序菜單畫面組指定的最小值和最大值,以14393

希望這有助於。