在这一行,我得到以下例外:
using (Stream reader = File.Open(m_inputFile, FileMode.Open))
例外:
The message is: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
在ExcelDNA中运行的Excel插件中会发生这种情况,但只要将XLL for Excel放在网络驱动器上,就会失败。
当我在安全的网络上时,如何允许完全权限从本地驱动器读取?
答案 0 :(得分:2)
这可能是由于.NET 2.0下的默认安全设置,它为通过网络运行的代码授予了受限制的权限。
第一步是确保您运行最新版本的Excel-DNA - 几年前有一些与AppDomain设置的安全性相关的更改可能是相关的。
您可以尝试的另一个修复方法是将您的加载项重新定位到.NET 4.0。您可能甚至不必重新编译,只需将.dna文件更改为:
<DnaLibrary RuntimeVersion="v4.0" Name="..." >
如果您想坚持使用.NET 2.0运行时,可以使用caspol
实用程序更改权限。此帖子中有一些关于Google论坛的详细说明:https://groups.google.com/d/msg/exceldna/Csls-_bjDp0/G3HlxFkDefQJ