System.Security.SecurityException

J

Jarod_24

How do i prevent getting a System.Security.SecurityException when running my
app from a Network Drive?

My app stopped when checking for a previous instance of itself using the
code:

Private Function prevInstance() As Boolean
Dim pProcess As Diagnostics.Process()
pProcess =
Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrent
Process.ProcessName)
If pProcess.Length > 1 Then Return True
Return False
End Function

Since the exception happened when using diagnostics.Process i assume that
this exception will be thrown then trying to start an app to, or when trying
to get the process's handle an so on to (wich my app does later on)

So how do i "request" or get my app to get the nesseceary "clearance" to do
these things.
 
D

Dot Net Team [MSFT]

As you've discovered, the security permissions given to applications run
over the intranet is different from security permission given to an
application run on your computer. There are a couple of ways to fix this:


1. Easier way - use the Microsoft frameworks configuration tool to give
the intranet Code group the full permission set.
WARNING - this takes away the extra safety given by the more
restrictive permission and may open holes in your security.
2. Harder way - Sign the project you've created, create a new Code group
with a test for the public key of your signed assembly, and give it full
permission.
This will allow the relaxed permission only for your signed
project, keeping increased security for everything else.


Here's an overall link to code access security:
ms-help://MS.MSDNQTR.80.en/cpguide/html/cpconCodeAccessSecurity.htm

Here's a link to using the frameworks configuration tool for security
policy.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconusingnetframeworkconfigurationtooltoconfiguresecuritypolicy.asp

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top