<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[James's Programming Page — errors from  catch (Exception ex)]]></title>
		<link>https://swforum.seekye.com/topic/10094/</link>
		<atom:link href="https://swforum.seekye.com/feed/rss/topic/10094/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in errors from  catch (Exception ex).]]></description>
		<lastBuildDate>Wed, 14 Jun 2017 03:33:03 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[errors from  catch (Exception ex)]]></title>
			<link>https://swforum.seekye.com/post/12959/#p12959</link>
			<description><![CDATA[<p>First I could not get the examples to compile using vars.. It kept complaining about tryOpen not being a member. So I have to use read class types. Now I get this... See comments in try catch. I can use HID.dll from my command line C application with a report ID of 18 using 4 and 2 as a write.&nbsp; So I know the device is good.</p><p>&nbsp; HidDeviceLoader loader = new HidDeviceLoader();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HidDevice device = loader.GetDevices(0x16d0, 0x0d04).First();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HidStream stream;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;device.TryOpen(out stream);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var bytes = new byte[device.MaxOutputReportLength];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bytes[0] = 18;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bytes[1] = 4;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bytes[2] = 1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int retry = 10;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while (retry&gt;0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stream.Write(bytes);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch (TimeoutException)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;retry--;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//retry<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch (Exception ex)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox.Show(&quot;Timeout waiting for API to respond: &quot; + ex.Message);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// ex.InnerException&nbsp; - The parameter is incorrect.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// ex.message&nbsp; operation failed early</p><br /><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return true;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//error out.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;finally<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stream.Close();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return false;</p>]]></description>
			<author><![CDATA[null@example.com (S_K_U_N_X)]]></author>
			<pubDate>Wed, 14 Jun 2017 03:33:03 +0000</pubDate>
			<guid>https://swforum.seekye.com/post/12959/#p12959</guid>
		</item>
	</channel>
</rss>
