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

serial port and securityexception

I have written a VB app using the RS323.vb code from the VB resource kit.
When I try to run the code from a network drive I get a securityexception
error. If I copy the file to the local c drive it works perfectly. I have
seen posts that say the best thing to do is change the runtime security
policys on the PCs. I would rather code the program so I don't have to
change the security policy at all. I have seen a few examples of permission
code but none are dealing with a serial port. Below is a partial copy of
the code I am trying to make work. I think I doing this correctly, but it
still gives the SecurityException when run on the network drive. Part of
the problem, I think, is which permission do I need to use in the Dim
compermission line? The ultimate goal is to put this application on a
network drive and let people use it without making any changes to the PC.
Can this be done? Thank you for your time.

Jason Dravet

'Imports System.Security
Imports System.Security.Permissions

Public Class Form1
Inherits System.Windows.Forms.Form
Private msCommPort As New Rs232
Dim setmute As Boolean = True
Dim volumelevel As Integer = 24
Dim compermission As FileIOPermission

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
compermission = New FileIOPermission(PermissionState.Unrestricted)
compermission.PermitOnly()
msCommPort.Open(1, 9600, 8, Rs232.DataParity.Parity_None,
Rs232.DataStopBit.StopBit_1, 4096)
msCommPort.Write("PON")
System.Threading.Thread.Sleep(5000)
msCommPort.Write("AVL:000")
msCommPort.Close()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
msCommPort.Open(1, 9600, 8, Rs232.DataParity.Parity_None,
Rs232.DataStopBit.StopBit_1, 4096)
msCommPort.Write("POF")
msCommPort.Close()
Button4.FlatStyle = Windows.Forms.FlatStyle.Flat
Button4.BackColor = Color.Gray
Button4.Text = "Muted"
End Sub
Nov 20 '05 #1
2 2963
Hi,
When you run a program of a network share, you will need to give full
trust permission to the network share by modifying the security setting.
You can do it using the following steps on the client machine

1.Open the Microsoft .NET Framework Configuration from
Administrative Tools.

2. Expand Runtime Security Policy->Machine->Code Groups.

3. Right-Click on All_Code and select new.

4. Choose "Create a new code group", and give it a relevant name such as the
name of the applications share then select Next.

5. On the next dialog choose URL from the drop-down list

6. In the URL dialog put the path to the share in this exact format
"file:////\\computername\sharename\*" where computername is the name of
the
computer hosting the remote share, and sharename is the name of the
share.

7. Click Next, and on the next page choose "Use an existing permission set,
and
choose Fulltrust from the drop-down list.

8. Click Next and then Finish.

B/ Use Caspol with the following syntax in a .NET command prompt

Caspol -machine -addgroup 1 -url "file:////\\computername\share\*" FullTrust
But you would have to do this from every machine. If you want the new
security policy to take effect from a single point, then you would have to
do the following

1. Configure the desired security policy on a machine (i.e. change the
trust for
the intranet zone, grant full trust to a specific assembly, etc. see
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpcons
ecuritypolicybestpractices.asp for .NET framework security best practices.

2. Open the .NET Framework Configuration Wizard, select "Runtime Security
Policy"
3. Run the "Create Deployment Package" wizard, select the security policy
you
would like to package, and create the package.
4. Deploy the msi package to the targeted machines via ACTIVE DIRECTORY
(group
policies), startup scripts, or by placing the msi package on a network
share for
users to run.

5. Once the msi package has been installed users should be able to use the
updated
security policy.

Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks

Nov 20 '05 #2
Thank you for the reply. The goal is to code the program so that I don't
have to make any changes to the PCs. I have seen what you posted in several
replies in this newsgroup, but this is not the solution I am looking for.
If this is the ONLY way to do this, that is fine, but again the goal of this
project is to not make ANY changes to the PC. If I do end up making changes
to the PCs why can't this be done via group policy? Again thank you for the
response and I am looking forward to your comments.

Jason
"Anand Balasubramanian(MSFT)" <an****@online.microsoft.com> wrote in message
news:tU**************@cpmsftngxa06.phx.gbl...
Hi,
When you run a program of a network share, you will need to give full
trust permission to the network share by modifying the security setting.
You can do it using the following steps on the client machine

1.Open the Microsoft .NET Framework Configuration from
Administrative Tools.

2. Expand Runtime Security Policy->Machine->Code Groups.

3. Right-Click on All_Code and select new.

4. Choose "Create a new code group", and give it a relevant name such as the name of the applications share then select Next.

5. On the next dialog choose URL from the drop-down list

6. In the URL dialog put the path to the share in this exact format
"file:////\\computername\sharename\*" where computername is the name of
the
computer hosting the remote share, and sharename is the name of the
share.

7. Click Next, and on the next page choose "Use an existing permission set, and
choose Fulltrust from the drop-down list.

8. Click Next and then Finish.

B/ Use Caspol with the following syntax in a .NET command prompt

Caspol -machine -addgroup 1 -url "file:////\\computername\share\*" FullTrust

But you would have to do this from every machine. If you want the new
security policy to take effect from a single point, then you would have to
do the following

1. Configure the desired security policy on a machine (i.e. change the
trust for
the intranet zone, grant full trust to a specific assembly, etc. see
http://msdn.microsoft.com/library/de...us/cpguide/htm l/cpcons
ecuritypolicybestpractices.asp for .NET framework security best practices.

2. Open the .NET Framework Configuration Wizard, select "Runtime Security
Policy"
3. Run the "Create Deployment Package" wizard, select the security policy
you
would like to package, and create the package.
4. Deploy the msi package to the targeted machines via ACTIVE DIRECTORY
(group
policies), startup scripts, or by placing the msi package on a network
share for
users to run.

5. Once the msi package has been installed users should be able to use the
updated
security policy.

Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights. Please reply to newsgroups only. Thanks

Nov 20 '05 #3

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

Similar topics

4
by: ^CeFoS^ | last post by:
Hello to everybody, I've done an application that draws in a frame the trajectory of a robot. The robot position is readed through the serial port, and several commands are wrote through the...
2
by: willie | last post by:
Hi, I'm writing a program which requires the use of three serial ports and one parallel port. My application has a scanning devices on each port, which I can access fine with pyserial. ...
3
by: collinm | last post by:
hi i send a command to a led display, the led display is suppose to return me some character i write a string on a serial port void ledDisplayExist() { char msg={'\0', '\0', '\0', '\0',...
13
by: Al the programmer | last post by:
I need to access the serial ports on my webserver from an asp.net page. I have no problem accessing the serial ports from a windows form application, but the code doesn't work in asp.net. I have...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
4
by: Frank | last post by:
Hello, how to get information about all serial ports in the PC? I use the following code, but i got only the data of the FIRST serial port. All other serial port information are not available...
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
4
by: rowan | last post by:
I'm writing a driver in Python for an old fashioned piece of serial equipment. Currently I'm using the USPP serial module. From what I can see all the serial modules seem to set the timeout when...
6
by: terry | last post by:
Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.