问题标签 [code-access-security]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
269 浏览

.net - 设置 CAS 策略

我有一个用户从文件服务器运行的 .NET 应用程序。.NET 程序集之一需要完全信任。我已经签署了大会。设置代码访问安全策略时,我要设置哪个版本的 .NET 框架策略?该应用程序是为使用 .NET Framework 1.1 版而构建的。我需要为每个框架设置策略吗?

0 投票
2 回答
6715 浏览

visual-studio-2010 - 具有代码访问安全性 NetFx40_LegacySecurityPolicy 的 .net 4.0 将不起作用

我正在尝试在使用 VS2010 beta 2 构建的 vsto office 插件中使用外部库 DevExpress.XtraTreeList.v8.1.dll。我收到以下编译时 错误:

DevExpress.Utils.AppareanceObject 抛出异常 --> System.NotSupportedException。

错误消息继续说,出于兼容性原因,我可以使用 NetFx40_LegacySecurityPolicy 开关。

我尝试将此配置变量放在以下所有位置:

1)我的应用程序配置文件。
2) C:\Windows\Microsoft.NET\Framework\v4.0.21006\msbuild.exe.config 3) C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\dev.exe.config

这些都没有解决问题。这是我使用过的参考资料。

重新启用 cas

msdn.microsoft.com/en-us/library/ee191568(VS.100).aspx

如何摆脱这个错误,以便在 vs 2010 中构建应用程序?

0 投票
0 回答
5458 浏览

asp.net - Intermittent PolicyException: Execution permission cannot be acquired

We are intermittently seeing the following exception shortly after an App Pool recycle in an ASP.NET application:

The specific DLL that fails to load varies from incident to incident, but is always one referenced by the main assembly.

We're running on ASP.NET 3.5 on Windows Server 2008. This seems to happen in batches affecting some but not all of sites on the same App Pool. We have a large number of sites all running the same code.

Once a site has failed to load a DLL it throws up a Yellow Screen of Death until the next App Pool recycle. We haven't been able to reproduce this behavior and the sites seem to work fine for days or weeks at a time (and many App Pool recycles) before failing.

Has anybody else seen similar behavior?

Update:

We've tried reproducing the failure by setting up a few hundred sites and writing a script to hit them repeatedly while recycling the App Pool once every couple of minutes and were unable to accomplish much other than loading down the server's CPU for a few days straight.

We then tried messing (locking one of the DLLs, changing the file permissions) with the copies of the DLLs that ASP.NET makes and managed to reproduce similar behavior but not the same exception.

Does anybody have any ideas on how to adjust the security policy to get it to throw a System.Security.Policy.PolicyException: Execution permission cannot be acquired. when loading a specific DLL?

0 投票
1 回答
979 浏览

code-access-security - 从网络共享加载的程序集上的 System.Type.GetCustomAttributes 未显示所有属性

我有一个托管 dll - repro.dll,其中包含装饰有 2 个属性的类 TestModuleCommand:System.ObsoleteAttribute 和 System.Management.Automation.CmdletAttribute(来自 Windows 7 中 GAC 中的 System.Management.Automation.dll)

如果将 repro.dll 放在本地目录中,我可以看到从 System.Type.GetCustomAttributes(false) 返回的两个属性。如果将 repro.dll 放在网络路径中,那么我只能看到一个属性(尽管我仍然可以通过 System.Reflection.CustomAttributeData.GetCustomAttributes(MemberInfo) 看到这两个属性)。这是不希望的——我想查看这两个属性(我知道实例化 CmdletAttribute 不会产生安全影响)。

根据我在网上找到的内容,我隐约知道 repro.dll(如果从网络位置加载)无法完全看到 SMAdll。我认为 CAS 允许我在 System.Management.Automation 中声明 CmdletAttribute 是安全的,但我无法弄清楚如何编写该声明。我在哪里可以阅读更多内容以完全了解正在发生的事情?欢迎任何智慧之言。

谢谢,

卢卡斯

PS。以下是任何人都可以在 powershell.exe 提示符下尝试的重现(在 Windows 7 中 - Add-Type cmdlet 在 PowerShell v2 中是新的):

0 投票
1 回答
603 浏览

sharepoint - 何时使用 SharePointPermissionAttribute

我什么时候需要用 SharePointPermission 属性修饰我的方法?我遇到了一些包含它们的代码示例,而有些则没有。

0 投票
2 回答
218 浏览

asp.net - 对 ASP.NET 的部分信任

ASP.NET 环境中的部分信任配置有多大用处?如果我有自己的服务器,由我完全管理控制,那么设置部分信任仅在以某种方式设法上传和执行恶意代码但无法通过 web.config 提高信任级别的攻击类型中有用。这样的攻击可能吗?

0 投票
1 回答
3629 浏览

.net - 是否有 CASPOL.exe GUI 命令行生成器?

是否有用于生成 CASPOL 命令的简单实用程序/GUI 应用程序?

0 投票
1 回答
362 浏览

c# - 如何访问 Silverlight .xap 文件下方文件夹中的相对位置文本文件?

WPF应用程序中,我使用xamlreader通过查找当前目录来加载 xaml 文件,如下所示:

所以我可以通过获取它的绝对路径来读取 .xaml 文件,如下所示:

在 Silverlight 中,GetDirectoryName(...) 方法给了我一个MethodAccessException

如何读取相对于 Silverlight 中的 .xap 文件的这些 .xaml 资源字典文件?

我可以想象我可以在其中放置一个名为“布局”的.xap 文件的目录,其中包含我可以读取的 .xaml 文件,但是相对于 URI在此 .txt 文件中读取的Silverlight 命令是什么.xap 文件恰好放置在哪个位置?

0 投票
1 回答
518 浏览

c# - 有没有比 permcalc 更好的工具来分析权限?

我有一些代码需要在中等信任下运行,但不需要。我过去使用过 permcalc,但是获取输出并将其与中等信任定义进行比较是相当痛苦的。我真正想要的是一个工具,它可以为我进行分析并输出我需要解决的问题的列表。这样的工具存在吗?我在 Visual Studio 中看到了对计算权限工具的引用,但在 VS2010 中的任何地方都找不到它。

0 投票
2 回答
254 浏览

asp.net - 是否有商业部署和使用的基于 .NET CAS(代码访问安全)的应用程序?

我在这里看到了一些关于 CAS 是什么以及如何使用它的主题。我的具体内容特别关注 CAS 的实际用法。

例如:

  • DotNetNuke 过去做了一些努力以能够在中等信任下运行:这仍然是真的吗?以部分信任(即不完全信任)运行的 DNN 的百分比是多少?哪些 DNN 模块以部分信任运行?)
  • Sharepoint 默认为从 bin 文件夹执行的 dll 上的部分受信任环境:在此 bin 文件夹中可以运行多少“商业”可用的 WebPart(不更改策略)?

这里的关键是能够指出 CAS 的成功案例,以便其他公司觉得他们也应该投资编写支持 CAS 的应用程序