Why does the .NET application start on a network drive when it crashes?

My .NET application does not work when starting from a network drive, even if the same executable works fine from the local hard drive?

I tried to check "Full Trust" like this:

try { // Demand full trust permissions PermissionSet fullTrust = new PermissionSet( PermissionState.Unrestricted ); fullTrust.Demand(); // Perform normal application logic } catch( SecurityException ) { // Report that permissions were not full trust MessageBox.Show( "This application requires full-trust security permissions to execute." ); } 

However, this does not help, and I mean that the application starts and the catch block is never entered. However, the debug build shows that the exception thrown is a SecurityException thrown by InheritanceDemand. Any ideas?

+31
c # networking securityexception
Sep 29 '08 at 14:21
source share
6 answers

This is really because applications in a network location are less trusted then on your local hdd (due to the default policy for the .NET platform).

If I'm not mistaken, Microsoft finally fixed this annoyance in .NET 3.5 SP1 (after many developers complained).

I google'd this: .NET Framework 3.5 SP1 Allows you to run managed code from a network share!

+22
Sep 29 '08 at 14:26
source share

Have you tried using CasPol for full Share trust ?

+14
Sep 29 '08 at 14:23
source share

You may have already done this, but you can use CasPol.exe to enable FullTrust for the specified network resource.

for example

 cd c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 CasPol.exe -m -ag 1.2 -url file:///N:/your/network/path/* FullTrust 

More details here .

+11
Sep 29 '08 at 14:26
source share

If it's .NET 2.0 or higher, ClickOnce was created to really help with this deployment stuff. I use this only for network resources.

+3
Sep 29 '08 at 14:25
source share

This is the security integrated by microsoft in the .net infrastructure. This is a way to stop malware running locally with full privileges, so you cannot change this programmatically in code.

What you need to do is increase trust in specific assemblies. You do this in the .NET Framework configuration (Control Panel-> Administrative Tools) and must be executed on each computer.

As with any safety precautions, this is a pain in the ass, but will help the world be less infected, etc.

0
Sep 29 '08 at 14:26
source share

All I had to do was mark the Read-Only files (possibly unrelated) and grant all permissions except full access to verified users. I ran into this problem before I did this when I had a network share for domain users only.

I found this workaround because neither the admin (\ server \ C $) nor my own PCs had this problem.

Edit: The application is for .NET 3.5, not SP1 here (version 3.5.7283)

0
Mar 06 '18 at 16:15
source share



All Articles