为什么我的 .NET 应用程序在从网络驱动器运行时会崩溃? [英] Why does my .NET application crash when run from a network drive?

查看:40
本文介绍了为什么我的 .NET 应用程序在从网络驱动器运行时会崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我用谷歌搜索了它:.NET Framework 3.5 SP1 允许从网络共享启动托管代码!

这篇关于为什么我的 .NET 应用程序在从网络驱动器运行时会崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆