我的.NET应用程序在从网络驱动器运行时会失败,即使完全相同的可执行文件在本地硬盘驱动器上运行得很好?
我尝试检查“完全信任”,如下所示:
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。有什么想法吗?
发布于 2008-09-29 14:26:39
这确实与网络位置上的应用程序比本地硬盘上的应用程序不受信任(由于.NET框架的默认策略)有关。
如果我没记错的话,微软最终在.NET 3.5 SP1中纠正了这个恼人的问题(在许多开发人员抱怨之后)。
我用谷歌搜索了一下:.NET Framework 3.5 SP1 Allows managed code to be launched from a network share!
发布于 2008-09-29 14:23:32
您是否尝试过使用CasPol to Fully Trust a Share
发布于 2008-09-29 14:26:14
您可能已经这样做了,但您可以使用CasPol.exe为指定的网络共享启用FullTrust。
例如
cd c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
CasPol.exe -m -ag 1.2 -url file:///N:/your/network/path/* FullTrust更多信息here。
https://stackoverflow.com/questions/148879
复制相似问题