TestApp does not start

Jul 30, 2012 at 9:24 PM

Hi !

I just want to give it a try, but nothings runs. No errormessages,

but no main window. I just downloaded the source and made

a fresh build [which succeeds with two warnings]. But even

this exe does not run.

Any ideas ?

++mabra

Coordinator
Jul 31, 2012 at 6:48 AM

Hi mabra,

Very strange...

Anything shown in the Output window in Visual Studio?

What happens if you download the .zip file containing the binary I have build. Can you execute that?

/mrtn

Jul 31, 2012 at 9:02 AM

Hi !

 

I am with XP, in my company, at the moment. Similar thing. On start, the debugger appears.

Just to be sure, I downloaded the latest source [16918] and build the project.

Here are the build errors:

 

Warning    1    CA1001 : Microsoft.Design : Implement IDisposable on 'MainViewModel' because it creates members of the following IDisposable types: 'BackgroundWorker'. If 'MainViewModel' has previously shipped, adding new members that implement IDisposable to this type is considered a breaking change to existing consumers.    D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\ViewModel\MainViewModel.cs    26    SimpleHIDTestApplication


Warning    2    CA2214 : Microsoft.Usage : 'MainViewModel.MainViewModel()' contains a call chain that results in a call to a virtual method defined by the class. Review the following call stack for unintended consequences:

MainViewModel..ctor()
MainViewModel.set_HidCaps(List<String>):Void
ObservableObject.RaisePropertyChanged(String):Void    D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\ViewModel\MainViewModel.cs    31    SimpleHIDTestApplication

 

The I run it an get this list of errors:

System.Windows.Markup.XamlParseException occurred
  Message='The invocation of the constructor on type 'SimpleHIDTestApplication.ViewModel.ViewModelLocator' that matches the specified binding constraints threw an exception.' Line number '5' and line position '8'.
  Source=PresentationFramework
  LineNumber=5
  LinePosition=8
  StackTrace:
       at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at SimpleHIDTestApplication.MainWindow.InitializeComponent() in d:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\MainWindow.xaml:line 1
       at SimpleHIDTestApplication.MainWindow..ctor() in D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\MainWindow.xaml.cs:line 16
  InnerException: System.ComponentModel.Win32Exception
       Message=Ein an das System angeschlossenes Gerät funktioniert nicht
       Source=SimpleHID
       ErrorCode=-2147467259
       NativeErrorCode=31
       StackTrace:
            at SimpleHID.HIDManager.GetSerialNumber(IntPtr handle) in D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHID\HIDManager.cs:line 92
            at SimpleHID.HIDManager.GetInfoSets() in D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHID\HIDManager.cs:line 43
            at SimpleHIDTestApplication.Model.Model.GetDevices() in D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\Model\Model.cs:line 13
            at SimpleHIDTestApplication.ViewModel.MainViewModel.ExecuteUpdate() in D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\ViewModel\MainViewModel.cs:line 277
            at SimpleHIDTestApplication.ViewModel.MainViewModel..ctor() in D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\ViewModel\MainViewModel.cs:line 271
            at SimpleHIDTestApplication.ViewModel.ViewModelLocator.CreateMain() in D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\ViewModel\ViewModelLocator.cs:line 123
            at SimpleHIDTestApplication.ViewModel.ViewModelLocator..ctor() in D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\ViewModel\ViewModelLocator.cs:line 74
       InnerException:

      
Error    1    Unable to load the metadata for assembly 'SimpleHIDTestApplication'. This assembly may have been downloaded from the web.  See http://go.microsoft.com/fwlink/?LinkId=179545.  The following error was encountered during load: Could not load file or assembly 'SimpleHIDTestApplication' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)    D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\App.xaml    1    1    SimpleHIDTestApplication


Error    2    The type 'vm:ViewModelLocator' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.    D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\App.xaml    5    8    SimpleHIDTestApplication


Error    3    Unable to load the metadata for assembly 'SimpleHIDTestApplication'. This assembly may have been downloaded from the web.  See http://go.microsoft.com/fwlink/?LinkId=179545.  The following error was encountered during load: Could not load file or assembly 'SimpleHIDTestApplication' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)    D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\MainWindow.xaml    1    1    SimpleHIDTestApplication


Error    4    The type 'WPF:HIDTemplateSelector' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.    D:\BuB\Dxchg\Download\Develop\Source\SimpleHID--SimpleHID-C#-16918-src\unpacked\Main\SimpleHIDTestApplication\MainWindow.xaml    50    6    SimpleHIDTestApplication


May be, this helps. My intial test [my first question] stems from use on Windows Server 2003 R2

and no debugger appeared.

 

Let me know, whats ongoing.

 

++mabra

 

Coordinator
Jul 31, 2012 at 12:26 PM

I think you have a device that does not support serial number. Can you please test this.

In HIDManager.cs:

    private static string GetSerialNumber(IntPtr handle)
    {
      var serialNumberString = new StringBuilder(128);
      if (NativeMethods.HidD_GetSerialNumberString(handle, serialNumberString, serialNumberString.Capacity) == false)
      {
        throw new Win32Exception();
      }
      return serialNumberString.ToString();
    }

Replace with this:

    private static string GetSerialNumber(IntPtr handle)
    {
      var serialNumberString = new StringBuilder(128);
      if (NativeMethods.HidD_GetSerialNumberString(handle, serialNumberString, serialNumberString.Capacity) == false)
      {
        return "";
      }
      return serialNumberString.ToString();
    }

What happens now?

Jul 31, 2012 at 1:16 PM

Hi !

Many thanks for your increditable fast reply!

Ok, it bombs again, see the whole errors:

 

System.NullReferenceException was unhandled by user code
  Message=Object reference not set to an instance of an object.
  Source=SimpleHID
  StackTrace:
       at SimpleHID.HIDDevice.ReadRawInputReport() in C:\Develop\SimpleHID\SimpleHID\HIDDevice.cs:line 270
       at SimpleHID.HIDDevice.ReadInputReport() in C:\Develop\SimpleHID\SimpleHID\HIDDevice.cs:line 288
       at SimpleHIDTestApplication.ViewModel.MainViewModel.bw_DoWork(Object sender, DoWorkEventArgs e) in C:\Develop\SimpleHID\SimpleHIDTestApplication\ViewModel\MainViewModel.cs:line 381
       at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
       at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
  InnerException:

 
The HIDDevice code:

private byte[] ReadRawInputReport()
    {
      var firstInputReportId = inputButtonCaps[0].ReportID;    //270
      var data = CreateRawInputReport(firstInputReportId);
      try
      {
        fileStream.Read(data, 0, data.Length);
      }
      catch (Exception)
      {
        throw new HIDDeviceException();
      }
      return data;
    }

Note: I'll not make stress here, I am just a USB beginner. My device is a teensy

with the raw HID sample: http://www.pjrc.com/teensy/rawhid.html

The sample windows app just shows 64 bytes from the device, which

itself, has currently only zeros. But it does not bomb. Unhandled or swallowed

exceptions are in my early experiments here a litte problematic.

 

Thanks for your help!

++mabra

Coordinator
Jul 31, 2012 at 4:32 PM

This one I knew. Get the update I just checked in (MainViewModel.cs)

/mrtn

Aug 2, 2012 at 9:59 AM

Hi !

I just this moment downloaded the new version. The TestApp comes up now with a dialog !!

But it tells mit, the buffers are 0x41 bytes, while my teensy is excactly sending and

receiving 0x40. Don't know, where this difference stems from or waht I am probably

not knowing. No further informations are provided, but I think, the teensy must - like

each usb device - have at minimum one report. Another thing is, that the Teensy

really has a serialnumber. I can see this with this lib:

http://www.zer7.com/software.php?page=hidsharp

When I terminate the testapp, the VS debugger appears, dont know, for which

reason. I just wanted to stepp through in VS, but this way, the dialog never

appears.

Regards,

++mabra