为什么我的.NET应用程序崩溃从网络驱动器上运行时?我的、应用程序、器上、网络

2023-09-02 01:36:00 作者:古道西风残照

我的.NET应用程序失败?

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." );
}

不过,这并没有帮助,我指的是在应用程序启动和catch块从未进入过。然而,调试版本显示,抛出的异常是引起的InheritanceDemand一个SecurityException。任何想法?

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?

推荐答案

它确实有做的其实是不太可信的网络位置上的这些应用程序,然后在您的本地硬盘(由于.NET框架的默认策略)。

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).

如果我没有记错的微软终于纠正了这个烦恼在.NET 3.5 SP1(后不少开发商抱怨)。

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

我google'd是:.NET Framework 3.5 SP1中允许管理code从网络共享启动!

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