473,785 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

serial port and securityexcepti on

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 securityexcepti on
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 SecurityExcepti on 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 FileIOPermissio n

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
compermission = New FileIOPermissio n(PermissionSta te.Unrestricted )
compermission.P ermitOnly()
msCommPort.Open (1, 9600, 8, Rs232.DataParit y.Parity_None,
Rs232.DataStopB it.StopBit_1, 4096)
msCommPort.Writ e("PON")
System.Threadin g.Thread.Sleep( 5000)
msCommPort.Writ e("AVL:000")
msCommPort.Clos e()
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
msCommPort.Open (1, 9600, 8, Rs232.DataParit y.Parity_None,
Rs232.DataStopB it.StopBit_1, 4096)
msCommPort.Writ e("POF")
msCommPort.Clos e()
Button4.FlatSty le = Windows.Forms.F latStyle.Flat
Button4.BackCol or = Color.Gray
Button4.Text = "Muted"
End Sub
Nov 20 '05 #1
2 2989
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
ecuritypolicybe stpractices.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******** ******@cpmsftng xa06.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
ecuritypolicybe stpractices.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
9094
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 same port to change the direction of the robot. The trajectory frame is managed by an applet, and the project works good when the applet is called by a html document allocated in the same local machine under W98 where the classes and the serial port...
2
13196
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. However, I'm unsure of how exactly I should be designing the program, I thought I could use threading to start class: class scanner(Thread): def __init__(self,port):
3
5055
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', '\0', '\1', 'Z', '0', '0',
13
4834
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 been told it is not possible to access the serial ports from asp.net. The application is used to control custom hardware. The hardware is connected to a PC through serial ports. Our customer wants to control the hardware from a remote...
4
11207
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. What I would like to do is make the serial port accessible via a web service. The web service and the legacy application would be running on the same machine. The mobile application would access the web service via a network connection. It...
4
17822
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 with this code sample: ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from WIN32_SerialPort");
13
6210
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 am sending a short message to a group of embedded boxes daisy chained via the serial port. When I send a 'global' message, all the connected units should reply with their Id and Ack in this format '0 Ack' To be certain that I didn't miss a...
4
11801
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 you open a serial port. This is not what I want to do. I need to change the timeout each time I do a "read" on the serial port, depending on which part of the protocol I've got to. Sometimes a return character is expected within half a second,...
6
6671
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 '%' to serial port and make sure it reached the serial port. 2. Once confirmed, send another character.
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10162
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.