473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Getting more info from exception

Regarding IOException
I'm catching this error while querying for available serial ports using a
third party component.
I attempt to open then close the comport and if this error type is thrown
then I don't list the port in a combo box.
But I would like to discern between a comport not being available and one
that is available but in use, easy with getlasterror.
Is it possible to do this?
Nov 16 '05 #1
3 992
Claire,

I think that the way that you are going about it isn't the best. If you
can, I would use the classes in the System.Management namespace to create a
WMI query for all instances of Win32_SerialPort. This would probably be
faster than looping through and catching exceptions (which is expensive).

An added benefit is that if you query for instances of Win32_SerialPort,
then you can get all the other information you need about it (if it is
available or not).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Claire" <bl****@blahhhhh.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Regarding IOException
I'm catching this error while querying for available serial ports using a
third party component.
I attempt to open then close the comport and if this error type is thrown
then I don't list the port in a combo box.
But I would like to discern between a comport not being available and one
that is available but in use, easy with getlasterror.
Is it possible to do this?

Nov 16 '05 #2
thanks Nicholas.
I think the knowledge of how to go about this is way beyond my few days xp
of C#.
Ive added the system.management reference to my project, took a look at the
help file and my heart dropped.
Are there some example code snippets somewhere that would give me a hint on
where to start (im working from home today so no reference books. Not even
sure if they would contain this sort of thing)

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oh**************@TK2MSFTNGP12.phx.gbl...
Claire,

I think that the way that you are going about it isn't the best. If you can, I would use the classes in the System.Management namespace to create a WMI query for all instances of Win32_SerialPort. This would probably be
faster than looping through and catching exceptions (which is expensive).

An added benefit is that if you query for instances of Win32_SerialPort, then you can get all the other information you need about it (if it is
available or not).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Claire" <bl****@blahhhhh.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Regarding IOException
I'm catching this error while querying for available serial ports using a third party component.
I attempt to open then close the comport and if this error type is thrown then I don't list the port in a combo box.
But I would like to discern between a comport not being available and one that is available but in use, easy with getlasterror.
Is it possible to do this?


Nov 16 '05 #3
I've found some code within the SelectQuery class.
Many thanks for your pointers, great :)
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: MJB | last post by:
I never get the above exception in Windows 2k. It only happens in Windows XP, which is the first oddity. My application is multi-threaded and I use the webbrowser control and media player. The...
4
by: Larry Tate | last post by:
I am wanting to get those cool html error pages that ms produces when I hit an error in asp.net. For instance, when I get a compilation error I get an html error page that shows me the ...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
3
by: Dave | last post by:
Hey all, I have a problem and I can't find anything on the net to really address it. We have a program at work that has lots of numbers on the front of the form because it is a control program...
20
by: Tim Reynolds | last post by:
Team, I am developing a web service. In testing in on my enw PC, I am expecting to see exceptions thrown appear on my browser. Instead I am getting an HTTP 500 Internal Server Error page and I am...
0
by: Steve | last post by:
Hi All, I have a Python script that uses SOAPpy and I'm outputting all of the methods and info about the parameters... I'm having trouble getting information out of the __init__ parameter. ...
1
by: MRamaLakshmi | last post by:
hi, I am developing an application using Java Applet which will be uploading files. Its throwing Null Pointer exception while detecting the proxy when we are trying to load the applet using Java6....
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
0
by: akash | last post by:
Hi, I've got some C# code instantiating a managed C++ class which in turn instantiates an unmanaged C++ class. I'm getting intermittent exceptions caught by my C# code, but the I can't get any...
9
by: Adem | last post by:
Is it possible to get some info about an unknown exception, ie. the "catch (...)" case below: catch (const blah1 &ex) { cout << "blah1 exception." << endl; } catch (const blah2 &ex) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.