So I've been battling this issue for about a week now and think I know the issue but I don't want to report an answer there until I have it pegged down.
In a nutshell, I get an IOException when trying to use the SerialPort.Open()
command. As it turns out, this is very common and most terminal programs actually do as well, but they simply ignore it. Please read my post above for the full tale. Now what I want to do is ignore the IOException but still open the serial port. I cannot do this with try/catch, or at least I don't know how.
I was wondering is there a way to try something and somehow state that "I know an issue will be thrown, it is a safe problem and I am choosing to ignore the exception and carry on with the task". To be clear, I don't want to ignore the error then move on. I want to ignore the error and still complete the operation.
Below is my best guess, but it doesn't work.
try
{
serialPort1.Open();
}
catch (System.IO.IOException)
{
MessageBox.Show("An IO Exception occurred.");
}
finally
{
//SAFELY IGNORE ERROR AND DO TASK ANYWAY HERE
}
If anyone could help me out with this I'd be most appreciative.
EDIT: If I just add the code serialport1.Open
afterwards I get:
This is basically the same thing that would happen without the try/catch. What I want to do is say I'm trying to do this: I don't care that it throws an error, do it anyway.