zoukankan      html  css  js  c++  java
  • LicenseContext.GetSavedLicenseKey 需要 FileIOPermission

    当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的描述可以参考:

    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

  • 相关阅读:
    团队博客创建
    筼筜湖美景
    作业11-网络
    作业11-多线程
    多线程-冲突与同步代码
    Java第12次实验提纲(JSP简单入门)
    作业-JSP简单入门
    Java Web参考资料
    面向对象设计大作业迭代任务
    在码云(gitee)上展开程序类课程教学
  • 原文地址:https://www.cnblogs.com/xixifusigao/p/2250002.html
Copyright © 2011-2022 走看看