LicenseContext.GetSavedLicenseKey 需要 FileIOPermission
2011-11-15 17:48
375 查看
当ASP.NET 运行于 Medium Trust 环境下,有两种情况:
Context.GetSavedLicenseKey(type, null), 会有SecurityException 抛出,提示需要FileIOPermission;
Context.GetSavedLicenseKey(type, assembly), 但assembly不为null时,可以正常使用。
怎样得到assembly, 大部分的时候都是通过Assembly.GetEntryAssembly() 获得。在ASP.NET环境下,Entry Assembly 一直是null.
怎么办?可以在AppDomain.CurrentDomain.GetAssemblies() 中搜索含有 xxx.licenses资源的assembly
有关于Medium Trust的描述可以参考:
OleDbPermission is not available. This means you cannot use the ADO.NET managed OLE DB data provider to access databases. However, you can use the managed SQL Server provider to access SQL Server databases.
EventLogPermission is not available. This means you cannot access the Windows event log.
ReflectionPermission is not available. This means you cannot use reflection.
RegistryPermission is not available. This means you cannot access the registry.
WebPermission is restricted. This means your application can only communicate with an address or range of addresses that you define in the <trust> element.
FileIOPermission is restricted. This means you can only access files in your application's virtual directory hierarchy. Your application is granted Read, Write, Append, and PathDiscovery permissions for your application's virtual directory hierarchy.
You are also prevented from calling unmanaged code or from using Enterprise Services.
http://msdn.microsoft.com/en-us/library/ff648344.aspx
Context.GetSavedLicenseKey(type, null), 会有SecurityException 抛出,提示需要FileIOPermission;
Context.GetSavedLicenseKey(type, assembly), 但assembly不为null时,可以正常使用。
怎样得到assembly, 大部分的时候都是通过Assembly.GetEntryAssembly() 获得。在ASP.NET环境下,Entry Assembly 一直是null.
怎么办?可以在AppDomain.CurrentDomain.GetAssemblies() 中搜索含有 xxx.licenses资源的assembly
有关于Medium Trust的描述可以参考:
Medium Trust Summary
The main constraints placed on medium trust Web applications are:OleDbPermission is not available. This means you cannot use the ADO.NET managed OLE DB data provider to access databases. However, you can use the managed SQL Server provider to access SQL Server databases.
EventLogPermission is not available. This means you cannot access the Windows event log.
ReflectionPermission is not available. This means you cannot use reflection.
RegistryPermission is not available. This means you cannot access the registry.
WebPermission is restricted. This means your application can only communicate with an address or range of addresses that you define in the <trust> element.
FileIOPermission is restricted. This means you can only access files in your application's virtual directory hierarchy. Your application is granted Read, Write, Append, and PathDiscovery permissions for your application's virtual directory hierarchy.
You are also prevented from calling unmanaged code or from using Enterprise Services.
http://msdn.microsoft.com/en-us/library/ff648344.aspx
相关文章推荐
- 新建百度地图基础版,出error inflating class com...错误,需要加SDKInitializer.initialize(getApplicationContext());
- post提交方式,get提交方式,context.Request.QueryString["key"],context.Request.Form["key"],context.Request.Params["key"],context.Request.["key"]
- How to get a TexturePacker license Key 如何获得免费的 TexturePacker license Key
- Context.GetObjectByKey 未找到具有标识{0}的类型的对象映射
- 使用 Context.getSharedPreferences 读不到 xml 里面的内容,但在应用的 Settings 页面是正常可以更改 xml 内容
- getApplicationContext()与this,getBaseContext() ---有时间翻译一下
- SecurityContextHolder.getContext().getAuthentication()为null的问题
- Caused by: java.lang.NoSuchMethodError:javax.servlet.http.HttpServletRequest.getServletContext()L
- 关于proplists:get_value/2 与lists:keyfind/3 的效率比较
- Django模板HTML中for循环遍历的是上下文context的key
- sudo apt-get install openssh-server时提示需要安装1:6.6p1-2ubuntu1的解决办法(图文详解)
- request.getContextPath()使用
- Android 中this、 getApplicationContext()、getApplication()之间的区别
- 首先需要安装JDK 6 sudo apt-get install sun-java6-jdk 之后需要设置默认的java程序 sudo update-alternatives --config java 按照提示输入对应的选项,指定为JDK 6
- 【Android】 context.getSystemService()浅析
- 通过ApplicationContext.getBean(beanName)动态加载数据。
- hread.currentThread().getContextClassLoader() and Class.getClassLoader()
- Java Map.get(key)类型判断空
- ActionContext.getContext()的用法
- WibuKey CodeMeter AxProtector CmActLicense CmDongle CodeMeter加密狗破解复制模拟