.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Imran Ghani
Post New Web Links

.NET bug or my fault?: Serial port fail to open from C# because spoolsv.exe and my application try t

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :.NET Framework
 
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


View Complete Post


More Related Resource Links

Serial port open fails because application and spoolsv.exe both try to access: Is this a .NET bug or

  
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 command line 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 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

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

Serial Port Application Leaks Handle After Exit Forcing Reboot to Clear

  

The application (C# .Net 3.5) available at www.redondowa.com/porttest demonstrates a problem encountered with a Sony VAIO multimedia laptop related to use of its serial modem port.  A discussion with MS support is included in a doc with the VS solution.

If the base stream or port is not closed before nulling the port, the port cannot be recreated and the application leaves the port inaccessible.  The machine requires a reboot to clear the error.  Other machines clear the error without requiring a reboot.

<!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:134; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch

bluetooth print via serial port PDA

  
Print via BlueTooth using PDA

Serial Port Communication Read and Write using C#.net

  
In this simple article you will learn that how you can Open and read COM port data using System.IO.Ports Namespace.
Simply just create New Project of windows application in C#.

Import ServiceProcess APIs
C#:
---
using System.IO.Ports

VB
Imports System.IO.Ports

Write Parsing functions which parse port data according to attached device

Open a windows application form names in another

  
Hi, Now i am in a horrible situation. I want to create an application for open another application(exe) and display all the form names in newly opened application in a compobox.If we selected a compobox item,ie;a form name in new application opened,i want to display all the control names in that form... is it possible? we can do it in same application.but how can i do it in another application? thanks in advance   Anoop

Serial Port with portable data terminal

  
Hi,I am making application with portable data terminal which connected to serial port. User will go with portable data terminal and scan data with it than we will connect it to PC and read all the data from it. Kindly somebody help me how to do that.Thanx

How to wait for a Serial Port to respond

  
Hi Is it to possible to wait for a serialPort component to complete it's response?  I have a device connected to the serial port of my PC. I use the serialPort component in order to communicate with the device. I have to send 2 different strings of data to the serial port but the trick is that after sending the first string of data I have to wait for the serial port to respond. Then I have to check the response and decide whether I must send the second string or not. Also after sending the second string, I have to check also the response of the serial port. I tried to use an arbitrary amount of wait time between the sending of the two strings. Something like SerialPort.Write(...) ; Thread.Sleep(2000); SerialPort.Write(...); But the software failed when I tried it in a slower PC. So is there a way to replace the Thread.Sleep(2000) with a command that will wait until the serial port complete its response? Although, the response of the serial port is different between the two sending strings, I do know that the first response is only one byte and I know the ending byte of the second response. Also, the second response is no more than 30 bytes in length. Regards Dimitris

Using a Port for WCF chat application

  
Hi All. I have a chat project using WCF over the internet. I will user TCPbinding for it. I will choose a port for connect from client. Anybody suggest me choose  the best port for me  ? Thanks so much!  

I cannot open application page which i created with Intranet and Internet.

  
for example, if i create an application portal : test:1000, then it is okay. but when i try to create an application portal: www.e.gov.au with ip address 192.168.1.100.  i have added  www.e.gov.au 192.168.1.100 into host files, but cannot open that page, system just said page not found. i just failed and failed. but when i checked in central admin, it is just fine....   can anybody tell me how to resolve it?   regards

Problem: Sessions got mixed up when open multiple tab for a sigle application

  
We got a problem that Sessions got mixed up when open multiple tab in a single application. We could change the code that do not use session variable in a that level, but a tons of page need to be modified. We need to find a quick fix for this problem. Is any thing we can do in code level to prevent user open multiple tab in a single application? O any thing we can do to keep its own session for a single tab?

know the port No. Of my web application at Runtime

  
I have many application in my solution. I have to move from a application to another. At the localhost, port no of different appliction is different. i want to know the port no for other application at run time so that i make a url to move another application.  

claims authenticated (FBA) user cannot open a connection to our custom application database

  
We have designed a custom sharepoint site. This site uses a membership provider that I implemented, and the users are stored in our custom application database. These are the steps I follow to reproduce the error: 1. Browse to our site. Select Forms Authentication from the default.aspx selection. 2. Enter in a username from our DB table. This user I have configured as a site collection administrator. 3. Login to the site. The user is authenticated by our membership provider and allowed access (ValidateUser returns true) 4. Browse to a page that attempts to connect to the custom app DB. 5. I get the following error when the page attempts to open a connection to our DB: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server NOTES: The code that opens the DB connection is running with SPSecurity.RunWithElevatedPrivileges. Our application pool account has access to the database. My user can connect to the database fine as well as the user that our  application pool is running as. I have validated the connection string that is being used in the debugger, and that is correct.

DataReceived event not triggered in vb.Net until serial port is closed & opened again

  
I am developing an application which sends multiple AT commands to a modem in VB.Net. After writing an AT command to the modem, I see the dataReceived event is not getting triggered until I close the port & open it again & write the next AT command. This behavior is consistent. As soon as I write the next AT command the response of previous AT command is read. Even adding a delay between the two write operations does not work. I also added a readData between the two writes so that data is read if it exist in buffer or stream but is not triggering datareceived event because bytestoread is non-zero, but that does not hep too. Because of insufficient read operations the data in readbuffer grows(accumulating) & after sometime the modem stops receiving the AT commands. Please suggest a solution code for data received handler & read data function   While comPort.BytesToRead > 0     Dim msgCharArray(255) As Char       If comPort.BytesToRead >= 256 Then     comPort.Read(msgCharArray, 0, 256)   Else    comPort.Read(msgCharArray, 0, comPort.BytesToRead)   End If   End While

application is faster while SSMS is open !?

  
Hi,  I have my VB.Net 2010 win form app running a job on a table (35.000 rows). I read from an MS-Access Database and, while iterantig on an OleDbDatareader,  I write  to the SQL Server Express 2008R2 using SqlDbCommand.ExecuteNonQuery. A progress bar on the GUI shows the current row. I've noticed that, while the app is running, if I launch the SSMS and I perform an operation (i.e. a simple select on a table) against the same db,  the application goes much more faster. As  I close the SSMS, the application slows down. All this is running on the same PC. In both, application and SSMS, the SQL Server Server Authentication is used (same user). Here is the connection string, stored into the app.config file:   <add name="DB" connectionString="Data Source=localhost\sqlExpress;Initial Catalog=myDb;Integrated Security=False;User ID=myUser;Password=myPass;pooling=False;Connection Timeout=1200;"/> Any idea ? thanks in advance. Francesco

Serial Port Conflict

  
Hi.... I have an issue related to serial port opening. when i run my software it gives me an error "serial port does not exit or already opened". I have two questions. 1.can i check which program is using com port. And how can i close serial port that is already being used.Using Windows7  

How do I open an application by clicking on a specific document from the list of documents on SP2010

  

 

I created my own file type. And I have an application to open this specific file (xml).  In SP2010 created a list of documents and have uploaded this file type on my list of specific documents and up to here everything is working fine. 

But when I click the file from the list of documents that he was open with my software or whether it is possible to synchronize with the file.
 
My application (WPF Application) is already prepared to receive through "CommandLineArgument" the name and location of the file. If I go to the folder where my file and make double click, my software starts and open the file.
 
How do I open t

open application in seperate browser when click on SiteMapNode

  

Hi All,

I want to open application in seperate browser when click on SiteMapNode.

Thanks in advance. 


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend