从网络驱动器运行时我的.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." );
}
Run Code Online (Sandbox Code Playgroud)
但是,这没有帮助,我的意思是应用程序启动并且永远不会输入catch块.但是,调试版本显示抛出的异常是由InheritanceDemand引起的SecurityException.有任何想法吗?
在MSDN FileSystemWatcher类页面上,它包含一个具有以下类属性的示例:
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
Run Code Online (Sandbox Code Playgroud)
这样做的目的是什么?什么时候应该包含还是不包括在内?
FileSystemWatcher类帮助页面位于:http: //msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx