Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Unexpected exception

Help
ytwong
2005-07-15
2013-03-22
  • ytwong
    ytwong
    2005-07-15

    Sorry I am an *absolute* newbie to serial comm. so my question may be dumb...

    I compiled the Test program within the solution package and I received this message:

    An unhandled exception of type 'System.UnauthorizedAccessException' occurred in serialport.dll
    Additional information: Attempted to perform an unauthorized operation.

    The weired thing is that it is coming and going, i.e. it works, (re-run) doesn't work, (re-run) works, (re-run) doesn't work....

    any help would be greatly appreciated!

    Thanks,
    Tony

     
    • Mr ChriZ
      Mr ChriZ
      2005-07-15

      Hi Tony
      I've been using this library for a month now.
      This exception usually occurs when the port is in use already.  Frustratingly at present there appears to be no way to detect if the ports in use by another program.  It can even be the same program but with more than one instance of the SerialPort class. 
      From what your saying working not working working etc it sounds like you are not closing the port correctly when you've finished with it.

      Make sure you do a serialCommsHandler.Close();

      before disposing of the objects.
      Hope this helps
      Mr (hriZ
      (Passer by) :-)

       
    • ytwong
      ytwong
      2005-07-18

      Thanks ChirZ for your help!
      I think I ran into the same problem like you did, that I couldnt tell what other programs are using the port...have you ever discovered a way to detect that?

      Tony

       
    • Mr ChriZ
      Mr ChriZ
      2005-07-19

      All I've done at the moment is put a
      try{}
      catch{}
      block around the .open method.
      If it catches something then it probably means ports not aquired.
      This is annoying in the debug enviroment however as it flags this exception every time i start!
      It would be good if the author could leave someway of detecting whether the port can be aquired, preferably before opening it, such as
      portIsAquirable method?
      (hriZ