Ports
May 18, 2013, 06:06:56 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Welcome to the PORTS Forum. Please post your questions, answers, and comments relating to USB and other hardware interfaces in the appropriate forums below. - Jan
Pages: [1]
  Print  
Author Topic: Exception thrown in C# Generic HID  (Read 749 times)
mihooper
Member
***
Posts: 19


« on: March 15, 2012, 06:41:18 am »

Joe (et al),

I am getting an exception in the Generic HID code. System.ObjectDisposedException was unhandled
 
Code:
  private void cmdOnce_Click( System.Object eventSender, System.EventArgs eventArgs )
        {             
            try
            {
                //  Don't allow another transfer request until this one completes.
                //  Move the focus away from cmdOnce to prevent the focus from
                //  switching to the next control in the tab order on disabling the button.
               
                fraSendAndReceive.Focus();
                cmdOnce.Enabled = false;
               
                ReadAndWriteToDevice();                 
            }
            catch ( Exception ex )
            {
                DisplayException( this.Name, ex );
                throw ;
            }
        }       

The exception details are as follows:
Quote
System.ObjectDisposedException was unhandled
  Message=Safe handle has been closed
  Source=mscorlib
  ObjectName=""
  StackTrace:
       at System.StubHelpers.StubHelpers.SafeHandleC2NHelper(Object pThis, IntPtr pCleanupWorkList)
       at GenericHid.Hid.HidD_GetInputReport(SafeFileHandle HidDeviceObject, Byte[] lpReportBuffer, Int32 ReportBufferLength)
       at GenericHid.Hid.GetInputReportViaControlTransfer(SafeFileHandle hidHandle, Byte[]& inputReportBuffer) in C:\Users\Mike\Documents\Visual Studio 2010\Projects\generic_hid_cs\Hid.cs:line 308
       at GenericHid.FrmMain.ExchangeInputAndOutputReports() in C:\Users\Mike\Documents\Visual Studio 2010\Projects\generic_hid_cs\FrmMain.cs:line 1390
       at GenericHid.FrmMain.ReadAndWriteToDevice() in C:\Users\Mike\Documents\Visual Studio 2010\Projects\generic_hid_cs\FrmMain.cs:line 1730
       at GenericHid.FrmMain.cmdOnce_Click(Object eventSender, EventArgs eventArgs) in C:\Users\Mike\Documents\Visual Studio 2010\Projects\generic_hid_cs\FrmMain.cs:line 1037
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at GenericHid.FrmMain.Main() in C:\Users\Mike\Documents\Visual Studio 2010\Projects\generic_hid_cs\FrmMain.cs:line 1942
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

I'm sure it is due to my client not responding properly, but for robustness I would like to fix this. Any ideas?

Thx,
MikeH
Logged

Thx,
MikeH
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1625


WWW
« Reply #1 on: March 16, 2012, 08:58:02 am »

I don't know the answer but a web search on the error message turns up some discussions that might be helpful.

For example

http://stackoverflow.com/questions/290583/what-is-causing-objectdisposedexception-from-serialport-while-debugging-net-win

Jan
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!