Assembly.LoadFrom()的权限管理在.NET 4.0中权限、LoadFrom、Assembly、NET

2023-09-03 17:25:36 作者:红尘过客

我有保安的麻烦,同时迁移应用程序从.NET 3.5至4.0。

I am having trouble with security while migrating an application from .NET 3.5 to 4.0.

我已经成功地从网络共享我已经映射到z启动应用程序: - Z:\ MyApp的\ APP.EXE。

I have an application that starts successfully from a network share I've mapped to z: - Z:\MyApp\App.exe.

该应用程序使用的加载项,并且有时要求从内网一个单独的位置加载组件 - Y:\ MyLib中\ Lib.dll

This application makes use of add-ins, and is sometimes asked to load assemblies from a seperate location on the Intranet - y:\MyLib\Lib.dll

在.NET 4.0中,我得到一个System.Security.Security例外,那么出现这种情况:

In .NET 4.0, I get a System.Security.Security exception then this happens:

System.IO.FileLoadException:未能加载文件或程序集'XXXX'或它的一个依赖。发生与安全有关的错误。 (从HRESULT异常:0x8013150A)---> System.Security.SecurityException:请求类型System.Security.Permissions.FileIOPermission,mscorlib程序,版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089'允许失败。

System.IO.FileLoadException: Could not load file or assembly 'XXXX' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A) ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

不过,如果我启动我的应用程序在本地从C:\ MyApp的\ APP.EXE,它能够与Assembly.LoadFrom()的插件为y成功加载:\ MyLib中\ Lib.dll

However, if I launch my application locally from C:\MyApp\App.exe, it is able to successfully load with Assembly.LoadFrom() the addin at y:\MyLib\Lib.dll.

什么我需要做的'祝福'的Y:?\ MyLib中的位置,使应用服务从网络共享运行被允许从那里执行code

What do I need to do to 'bless' the y:\MyLib location so that apps running from network shares are allowed to execute code from there?

谢谢, 戴夫

推荐答案

我有一个类似的问题,我能解决它作为我的问题是描述 http://stackoverflow.com/questions/3290735/structuremap-does-not-load-registries-when-started-from-network-drive. 我希望这能解决你的问题也。

I had a similar problem, I was able to solve it as is described in my question http://stackoverflow.com/questions/3290735/structuremap-does-not-load-registries-when-started-from-network-drive. I hope this solves your problem also.

 
精彩推荐
图片推荐