0

I am a complete newbie to the AllJoyn Windows implementation. I was trying out the Toaster example AllJoyn Studio VS Extension sample to understand the AllJoyn Producer Consumer capabilities as bundled with Windows 10. First of all the code in that sample link is not compatible with the latest AllJoyn library Alljoyn Studio Watcher class not generated. Hence I used the code from the AllJoyn Producer and Consumer experiences samples provided as a part of the Windows-Universal-Samples and modified it to adapt the Toaster example. While I can build the solution fine, but I am encountering a very esoteric runtime error when I am trying to create the instance of the Watcher class. The code where the the error is happening is:

    private AllJoynBusAttachment toasterBusAttachment;
    private DeviceWatcher watcher;
    private ToasterConsumer consumer;

    public ToasterConsumerLib()
    {
        toasterBusAttachment = new AllJoynBusAttachment();
        // This is the error line 
          watcher = AllJoynBusAttachment.GetWatcher(new List<string> { 
          "org.alljoyn.example.Toaster" }); 
        watcher.Added += Watcher_Added;
        watcher.Start();

    }

The error details is as follows: An exception of type 'System.InvalidCastException' occurred in ToasterSample.exe but was not handled in user code Additional information: Unable to cast object of type 'System.__ComObject' to type 'Windows.Devices.AllJoyn.IAllJoynBusAttachmentStatics'.

My platform is

  • Windows 10 Anniversary Edition(10.0, Build 14393) with all latest updates
  • Visual Studio 2015 with the AllJoyn Studio Extension

I am not very sure on how should I go about trying to troubleshoot this issue. Any pointers in the right direction will be very helpful.

koder
  • 887
  • 9
  • 29
  • I can't reproduce your issue by this small piece of code. How did you modify Producer and Consumer experiences samples? – Rita Han Jun 06 '17 at 06:09
  • I did not modify the code from the Producer Consumer experience samples. I was writing a small POC to test the Toaster sample and only used the new API to get a reference to the Watcher object from the consumer experience sample. I do realize that my original post hints at the fact that I have adapted the producer consumer experience sample code but that was not correctly worded. – koder Jun 06 '17 at 12:50
  • If you can provide complete code that produced this issue I can do more test. – Rita Han Jun 07 '17 at 09:13

0 Answers0