473,386 Members | 1,873 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,386 software developers and data experts.

Serial Communications in ASP.NET


Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1 PORT.

We have tried unsuccessfully to get this to work. We have tried the following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
May 31 '06 #1
5 2299
Your app is running as ASPNET not IUSR_ if I remember correctly. You can
change the user that the application pool that the application runs in. I
would however re-think your architecture as a webserver has no business
being connected to a serial port. I might make a remoting service that
handles the serial port then make a webservice front end.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:F4**********************************@microsof t.com...

Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when
we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1
PORT.

We have tried unsuccessfully to get this to work. We have tried the
following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the
webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client
application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.

May 31 '06 #2

Greg - what do you mean by "...I would however re-think your architecture
as a webserver has no business being connected to a serial port..."? I have
no idea of what you are talking about. If you call up VS 2005 - WebForms -
the SerialPort component is there waiting to be used. Why not use it? Also -
I have found many code examples illustrating exactly what I am successfully
doing already. And they're using ASP.NET. I don't understand this and I feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

"Greg Young" wrote:
Your app is running as ASPNET not IUSR_ if I remember correctly. You can
change the user that the application pool that the application runs in. I
would however re-think your architecture as a webserver has no business
being connected to a serial port. I might make a remoting service that
handles the serial port then make a webservice front end.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:F4**********************************@microsof t.com...

Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when
we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1
PORT.

We have tried unsuccessfully to get this to work. We have tried the
following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the
webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client
application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.


May 31 '06 #3

I'm sorry - I'm having troubles with the permissions part...

--
Franklin M. Gauer III

"Franklin M. Gauer III" wrote:

Greg - what do you mean by "...I would however re-think your architecture
as a webserver has no business being connected to a serial port..."? I have
no idea of what you are talking about. If you call up VS 2005 - WebForms -
the SerialPort component is there waiting to be used. Why not use it? Also -
I have found many code examples illustrating exactly what I am successfully
doing already. And they're using ASP.NET. I don't understand this and I feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

"Greg Young" wrote:
Your app is running as ASPNET not IUSR_ if I remember correctly. You can
change the user that the application pool that the application runs in. I
would however re-think your architecture as a webserver has no business
being connected to a serial port. I might make a remoting service that
handles the serial port then make a webservice front end.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:F4**********************************@microsof t.com...

Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when
we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1
PORT.

We have tried unsuccessfully to get this to work. We have tried the
following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the
webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client
application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.


May 31 '06 #4
Which part on the permissions?

As for my architecture comment.

The SerialPort would be owned by a single ASP.NET worker process
http://www.codeproject.com/aspnet/aspwp.asp (it would in fact belong to a
single app domain).. you could therefor only ever have a single ASP.NET
worker process... You could not scale yourself to support multiple worker
processes (let alone multiple web servers). You could not for instance run
with an application pool setup to use 10 worker processes (1 would work and
then 9 would fail to open the serial port).

As a rule of thumb, it is best to keep resources like this out of your web
processes as you can then scale the web processes.

http://www.microsoft.com/downloads/t...yLang=en&oRef=
is a useful document .. see "Resource Affinity" in chapter 6.

A perfect example of where this could kill your performance would be the
case where you are polling for a set of data that could be accessed throguh
your webservice via some data methods and exposed a few methods that caused
data to be executed accross the port. By moving the serial port out of the
web process you could feasably have 50 webservers using the same serial port
(in a case where they were mostly having people ask for data methods that
would simply hit their local cache this would in fact be a great
architecture).

The other problem I see alot of with this type of setup is that the ASP.NET
worker processes prefer to restart themselves occasionally. By placing the
serial port code in the web app you miss any polling etc over that port that
would need to be done during this period of time.

The last problem I see, you have already run into. Your code must run in at
an elevated privilege level which opens up far more sruface area for
possible attacks on your system (as opposed to a small component running
with elevated privs your entire app must now run with elevated privs or you
must take other measures within your application to only run certain areas
with elevated permissions). Doing something like making the ASPNET_WP
account an administrator on your system is certainly bad.

Have you tried to get the current identity to see who you are running as?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:C8**********************************@microsof t.com...

I'm sorry - I'm having troubles with the permissions part...

--
Franklin M. Gauer III

"Franklin M. Gauer III" wrote:

Greg - what do you mean by "...I would however re-think your
architecture
as a webserver has no business being connected to a serial port..."? I
have
no idea of what you are talking about. If you call up VS 2005 -
WebForms -
the SerialPort component is there waiting to be used. Why not use it?
Also -
I have found many code examples illustrating exactly what I am
successfully
doing already. And they're using ASP.NET. I don't understand this and I
feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

"Greg Young" wrote:
> Your app is running as ASPNET not IUSR_ if I remember correctly. You
> can
> change the user that the application pool that the application runs in.
> I
> would however re-think your architecture as a webserver has no business
> being connected to a serial port. I might make a remoting service that
> handles the serial port then make a webservice front end.
>
> Cheers,
>
> Greg Young
> MVP - C#
> http://geekswithblogs.net/gyoung
> "Franklin M. Gauer III" <Fr***************@discussions.microsoft.com>
> wrote
> in message news:F4**********************************@microsof t.com...
> >
> > Hi All,
> >
> > I've written an ASP.NET application (webservice) that does simple
> > serial
> > communications via the .NET 2.0 SerialComm object.
> >
> > The application runs fine on my development machine. The problem is
> > when
> > we
> > try to deploy it to another machine we receive: ACCESS IS DENIED TO
> > COM1
> > PORT.
> >
> > We have tried unsuccessfully to get this to work. We have tried the
> > following:
> > 1) Assign the IUSR.... account to Administrators
> > 2) We have actually had the local administrator account run the
> > webservice
> > 3) rebooted
> > 4) stopped and restarted IIS - etc. etc.
> >
> > We are unable to resolve this. Is there a special permission that the
> > account needs? Once again we are running XP Pro and it works fine in
> > development but we can't get it to run on this other machine!!!!
> >
> > Also - we have implemented the same code using a regular client
> > application
> > and it works fine (i.e. copied all the code out and put it in a
> > simple
> > windows form and we're fine).
> >
> > The problem is running it as a webservice. It does not work!
> >
> > Any thoughts - comments are appreciated! Thanks!
> >
> > --
> > Franklin M. Gauer III
> > Applications Development Manager
> > Integrated Companies, Inc.
>
>
>

May 31 '06 #5

Thanks Greg for your clarifications. This has helped me out tremendously. I
appreciate it.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"Greg Young" wrote:
Which part on the permissions?

As for my architecture comment.

The SerialPort would be owned by a single ASP.NET worker process
http://www.codeproject.com/aspnet/aspwp.asp (it would in fact belong to a
single app domain).. you could therefor only ever have a single ASP.NET
worker process... You could not scale yourself to support multiple worker
processes (let alone multiple web servers). You could not for instance run
with an application pool setup to use 10 worker processes (1 would work and
then 9 would fail to open the serial port).

As a rule of thumb, it is best to keep resources like this out of your web
processes as you can then scale the web processes.

http://www.microsoft.com/downloads/t...yLang=en&oRef=
is a useful document .. see "Resource Affinity" in chapter 6.

A perfect example of where this could kill your performance would be the
case where you are polling for a set of data that could be accessed throguh
your webservice via some data methods and exposed a few methods that caused
data to be executed accross the port. By moving the serial port out of the
web process you could feasably have 50 webservers using the same serial port
(in a case where they were mostly having people ask for data methods that
would simply hit their local cache this would in fact be a great
architecture).

The other problem I see alot of with this type of setup is that the ASP.NET
worker processes prefer to restart themselves occasionally. By placing the
serial port code in the web app you miss any polling etc over that port that
would need to be done during this period of time.

The last problem I see, you have already run into. Your code must run in at
an elevated privilege level which opens up far more sruface area for
possible attacks on your system (as opposed to a small component running
with elevated privs your entire app must now run with elevated privs or you
must take other measures within your application to only run certain areas
with elevated permissions). Doing something like making the ASPNET_WP
account an administrator on your system is certainly bad.

Have you tried to get the current identity to see who you are running as?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:C8**********************************@microsof t.com...

I'm sorry - I'm having troubles with the permissions part...

--
Franklin M. Gauer III

"Franklin M. Gauer III" wrote:

Greg - what do you mean by "...I would however re-think your
architecture
as a webserver has no business being connected to a serial port..."? I
have
no idea of what you are talking about. If you call up VS 2005 -
WebForms -
the SerialPort component is there waiting to be used. Why not use it?
Also -
I have found many code examples illustrating exactly what I am
successfully
doing already. And they're using ASP.NET. I don't understand this and I
feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

"Greg Young" wrote:

> Your app is running as ASPNET not IUSR_ if I remember correctly. You
> can
> change the user that the application pool that the application runs in.
> I
> would however re-think your architecture as a webserver has no business
> being connected to a serial port. I might make a remoting service that
> handles the serial port then make a webservice front end.
>
> Cheers,
>
> Greg Young
> MVP - C#
> http://geekswithblogs.net/gyoung
> "Franklin M. Gauer III" <Fr***************@discussions.microsoft.com>
> wrote
> in message news:F4**********************************@microsof t.com...
> >
> > Hi All,
> >
> > I've written an ASP.NET application (webservice) that does simple
> > serial
> > communications via the .NET 2.0 SerialComm object.
> >
> > The application runs fine on my development machine. The problem is
> > when
> > we
> > try to deploy it to another machine we receive: ACCESS IS DENIED TO
> > COM1
> > PORT.
> >
> > We have tried unsuccessfully to get this to work. We have tried the
> > following:
> > 1) Assign the IUSR.... account to Administrators
> > 2) We have actually had the local administrator account run the
> > webservice
> > 3) rebooted
> > 4) stopped and restarted IIS - etc. etc.
> >
> > We are unable to resolve this. Is there a special permission that the
> > account needs? Once again we are running XP Pro and it works fine in
> > development but we can't get it to run on this other machine!!!!
> >
> > Also - we have implemented the same code using a regular client
> > application
> > and it works fine (i.e. copied all the code out and put it in a
> > simple
> > windows form and we're fine).
> >
> > The problem is running it as a webservice. It does not work!
> >
> > Any thoughts - comments are appreciated! Thanks!
> >
> > --
> > Franklin M. Gauer III
> > Applications Development Manager
> > Integrated Companies, Inc.
>
>
>


Jun 1 '06 #6

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

Similar topics

1
by: Andreas Horneff | last post by:
Hi @ all, I've got a problem with serial communication in Borland C++ Builder. I've already found a lot of stuff about serial communication in the internet, but it dosen't work. What I want...
6
by: Peter Krikelis | last post by:
Hi All, I am having a problem setting up input mode for serial communications. (Sorry about the long code post). The following code is what I use to set up my comm port.
3
by: Ramakant Kasar | last post by:
Hi, If an application is reading data from a serial port, How can I open the same serial port with another application? Any idea? Please help. Thanks, Ramakant K.
2
by: K.K. | last post by:
I am writing program that will recieve or sent data to selected port (users can select which port they want to recieve or sent) but I don't know how or whick object I can use.
4
by: Ben Zhu | last post by:
I have a small project, which need use both RS232 port and excel for data plot. I considering use excel VB macro for the entire project. Although I used serial port extensively in MFC, I am not...
0
by: David | last post by:
I am having trouble with "ACCESS DENIED" error messages in a VB.NET 2003 application when attempting to open serial comms ports. The application has 2 ports that connect via serial cable to 2...
4
by: Gary Frank | last post by:
I'd like to write a program in VB.Net that handles serial communications to several devices. VB.Net 2003 does not have adequate built-in serial communications. I heard that 2005 will have that. ...
8
by: vicky | last post by:
Hello,I met a question when I wrote the program.I want the program can transmit the data frame continuosly through the RS232 when the communication has been interrupted.But I don't know how to...
5
by: LongBow | last post by:
Hello, Is there a way, in .NET, to determine what are the avialable Serial (Communications) Ports on a Windows OS and is there a way to determine that port isn't being use other than attempting...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.