title: Exception in AllJoyn studio demo code in VS 2015
body: <p>I am a complete newbie to the AllJoyn Windows implementation. I was trying out the Toaster example <a href="https://developer.microsoft.com/en-us/windows/iot/Docs/AllJoynStudio" rel="nofollow noreferrer">AllJoyn Studio VS Extension sample</a> 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 <a href="https://social.msdn.microsoft.com/Forums/en-US/e78796f3-db12-4013-ae7f-42c4db6e3d51/alljoyn-studio-watcher-class-not-generated?forum=WindowsIoT" rel="nofollow noreferrer">Alljoyn Studio Watcher class not generated</a>. Hence I used the code from the AllJoyn Producer and Consumer experiences samples provided as a part of the  <a href="https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/AllJoyn/ProducerExperiences" rel="nofollow noreferrer">Windows-Universal-Samples</a> 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:</p>
  
  <pre><code>    private AllJoynBusAttachment toasterBusAttachment;
      private DeviceWatcher watcher;
      private ToasterConsumer consumer;
  
      public ToasterConsumerLib()
      {
          toasterBusAttachment = new AllJoynBusAttachment();
          // This is the error line 
            watcher = AllJoynBusAttachment.GetWatcher(new List&lt;string&gt; { 
            "org.alljoyn.example.Toaster" }); 
          watcher.Added += Watcher_Added;
          watcher.Start();
  
      }
  </code></pre>
  
  <p>The error details is as follows: <strong>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'.</strong></p>
  
  <p>My platform is </p>
  
  <ul>
  <li>Windows 10 Anniversary Edition(10.0, Build 14393) with all latest updates</li>
  <li>Visual Studio 2015 with the AllJoyn Studio Extension</li>
  </ul>
  
  <p>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.</p>