Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my .NET application crash when run from a network drive?

My .NET application fails when run from a network drive even when the very same executable runs perfectly fine from a local hard drive?

I tried checking for "Full trust" like so:

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 isn't helping, by which I mean the application starts up and the catch block is never entered. However, a debug build shows that the exception thrown is a SecurityException caused by an InheritanceDemand. Any ideas?

like image 277
Paul Smith Avatar asked Sep 29 '08 14:09

Paul Smith


2 Answers

It indeed has to do with the fact the apps on a network location are less trusted then on your local hdd (due to the default policy of the .NET framework).

If I'm not mistaken Microsoft finally corrected this annoyance in .NET 3.5 SP1 (after a lot of developers complaining).

I google'd it: .NET Framework 3.5 SP1 Allows managed code to be launched from a network share!

like image 88
Davy Landman Avatar answered Oct 24 '22 01:10

Davy Landman


Did you try Using CasPol to Fully Trust a Share?

like image 14
Gulzar Nazim Avatar answered Oct 23 '22 23:10

Gulzar Nazim