使用网络共享中的引用 DLL 运行 C# 程序时访问被拒绝
我正在开发两个项目,它们都由 ClearCase 管理,这意味着对于 Windows,它们看起来像是位于网络共享上。
第一个项目是使用 VS 2003 用托管 C++ 编写的 DLL,旨在为一些用 VS2003 C++ 编写的遗留 DLL 提供托管接口。
第二个项目是用 C#(.NET 3.5、VS2008)编写的,包含第一个项目生成的 DLL,作为通过包装器使用旧版 DLL 的参考。
现在,当我尝试启动 C# 项目时,收到以下错误消息:
FileLoadException 未处理
无法加载文件或程序集 '(我的托管 C++ 包装器),Version=(version 数),文化=中立, PublicKeyToken=null' 或其之一 依赖关系。 访问被拒绝。
查看详细信息,这是一个包含内部 System.UnauthorizedAccessException 的 System.Io.FileLoadException(“访问被拒绝。(Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))”
现在,当我将 C# 项目复制到本地硬盘时,一切工作正常,即使托管 C++ 项目保留在网络驱动器上,
我之前也遇到过网络驱动器的权限问题,但在升级到 .NET 3.5 SP1 时这些问题消失了,我还尝试将 All_Code 代码组的权限集更改为“按照互联网上的建议,对 .Net 配置 1.1. 和 2.0 进行“完全信任”,但这也没有帮助。顺便说一句,我还检查了 DLL 是否是只读的,但事实并非如此。
提前感谢您的帮助!
更新:我还尝试使用强名称对两个程序集进行签名,并给予这些密钥完全信任,但没有成功,一定有其他原因,但我没有想法。
I am developing two projects which are both managed by ClearCase, which means that for Windows, it looks like they are located on a network share.
The first project is a DLL written using VS 2003 in managed C++ and is intended to provide a managed interface for some legacy DLLs written in VS2003 C++.
The second project is written in C# (.NET 3.5, VS2008) and includes the DLL generated by the first project as a reference to make use of the legacy DLLs via the wrapper.
Now when I try to start the C# project, I get the following error message:
FileLoadException was unhandled
Could not load file or assembly
'(my managed c++ wrapper), Version=(version
number), Culture=neutral,
PublicKeyToken=null' or one of its
dependencies. Access is denied.
Looking at the details, this is a System.Io.FileLoadException containing an inner System.UnauthorizedAccessException ("Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
Now when I copy the C# project to the local hard drive, everything works fine, even if the managed C++ project stays on the network drive.
I've had permission problems with network drives before but these vanished when upgrading to .NET 3.5 SP1. I also tried changing the Permission Set for the All_Code code group to "Full Trust" for .Net Configuration 1.1. and 2.0, as suggested on the internet, but this did not help either. Btw, I also checked if the DLL is readonly, but it isn't.
Thanks in advance for any help!
Update: I also tried signing both assemblies with a Strong Name and giving these keys full trust but to no avail. There must be some other reason but I am out of ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您需要设置代码访问安全策略以允许此位置
http://msdn.microsoft.com/en-us/library/930b76w0(VS.71).aspx
按照本文中大约 1/3 的说明进行操作(带屏幕截图):-)
http://www.15seconds.com/Issue/040121.htm
it sounds like you need to set your Code Access Security Policy to allow this location
http://msdn.microsoft.com/en-us/library/930b76w0(VS.71).aspx
Follow the instructions about 1/3 the way down this article (with screenshots) :-)
http://www.15seconds.com/Issue/040121.htm