Joe (et al),
I am getting an exception in the Generic HID code. System.ObjectDisposedException was unhandled
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:
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