locked
.NET bug or my fault?: Serial port fail to open from C# because spoolsv.exe and my application try to open port at the same time RRS feed

  • Question

  • Dear all,
    after browsing around I could not find any answer to my issue.

    I'm writing a program in C# to access a serial device. The serial device comes with a legacy DLL probably written in C++ that provides an OpenDevice (which I call via DLLImport). The device is connected to a USB port via a Prolific USB to serial converter.
    My problem is that 1 out of 5 times, the OpenDevice fails when I run my application. I have workaround to call it until it succeeds and it never goes beyond 3 or 4 tries.
    By monitoring the serial port with Portmon I noticed that:
    1) when running the application in debug mode from Visual studio the Com port is open from my process (MyApplication.EXE)
    2) when running from windows the Com port communication belongs to windows print spooler service (spoolsv.exe) but Portmon also tracks an open command from MyApplication.EXE and here the collision happens: I'm suprised to see that the main communication from MyApplication is managed by spoolsv.exe so it is not just spoolsv.exe running in the background: I'm calling it!
    3) the demo software from the supplier uses the same DLL but it is written in C++ and when I run it, spoolsv.exe does not show up (and open port never fails!)

    I do not understand what is the trigger that makes the calls going through spoolsv.exe or directly to the port and why, if .NET uses spoolsv.exe, there is also an Open port command from my application: is it a .NET bug? I'm sure it is not but I could find any other explanation.
    Does anybody have an insight on serial port handling in .NET when a legacy DLL and a serial to USB converter are on the path? I would like to connect directly to serial port without the spooler since this is not a printer, but I cannot disable spooler service on the PC because it is needed for the printers. I know it is possible because both Visual studio debug environement and the supplier application achieve this result: my .NET production application is the only one that invokes the spoolsv.exe to communicate to the COM port.

    Best regards and thankyou for help to any that could bring some understanding on this topic.
    Thursday, December 2, 2010 10:39 PM

Answers

  • Hi Claudio1969

    You can submit your suggestions to Microsoft Connect feedback portal http://connect.microsoft.com, Microsoft engineers will evaluate them seriously, thanks.

    If this issue is urgent, please contact support at http://support.microsoft.com.


    Best Regards,


    Please mark the right answers which satisfy your requirements.That will be helpfull for all community members. Thanks, Cookie
    • Marked as answer by eryang Thursday, December 16, 2010 10:05 AM
    Thursday, December 9, 2010 7:47 AM
  •  

     

    We would need a small repro in order to troubleshoot exactly what is going on here, and a support case would need to be opened to do that due to the time involved.

     That said, the spooler takes ownership of any ports that have printers installed on them, and you can no longer reliably communicate over those ports.  The only way to avoid this is to disassociate the spooler with the port entirely (either by uninstalling any printer objects on that port, or, by turning the spooler service off).

    My suggestion is to see about what options to check out. Here is some info for more in depth level into the problems through support.

    There are various support options such as advisory and per issue. Please visit the below link to see the various paid

    support options that are available to better meet your needs.

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone


    bill boyce
    • Marked as answer by eryang Monday, December 13, 2010 10:15 AM
    Friday, December 10, 2010 4:18 PM

All replies

  • Hi Claudio1969

    You can submit your suggestions to Microsoft Connect feedback portal http://connect.microsoft.com, Microsoft engineers will evaluate them seriously, thanks.

    If this issue is urgent, please contact support at http://support.microsoft.com.


    Best Regards,


    Please mark the right answers which satisfy your requirements.That will be helpfull for all community members. Thanks, Cookie
    • Marked as answer by eryang Thursday, December 16, 2010 10:05 AM
    Thursday, December 9, 2010 7:47 AM
  •  

     

    We would need a small repro in order to troubleshoot exactly what is going on here, and a support case would need to be opened to do that due to the time involved.

     That said, the spooler takes ownership of any ports that have printers installed on them, and you can no longer reliably communicate over those ports.  The only way to avoid this is to disassociate the spooler with the port entirely (either by uninstalling any printer objects on that port, or, by turning the spooler service off).

    My suggestion is to see about what options to check out. Here is some info for more in depth level into the problems through support.

    There are various support options such as advisory and per issue. Please visit the below link to see the various paid

    support options that are available to better meet your needs.

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone


    bill boyce
    • Marked as answer by eryang Monday, December 13, 2010 10:15 AM
    Friday, December 10, 2010 4:18 PM