• swig编译GDAL的C#库时遇到的代码安全问题及解决方法


      之前一直用的是别人编译好的gdal库开发,今天自己编译了gdal的2.0.0版本,踩了不少坑,但总算解决了。

      编译方法主要参考http://blog.csdn.net/liminlu0314/article/details/6945452,踩到的坑及解决方法参考http://www.cnblogs.com/yeahgis/archive/2013/04/10/3011553.html。但是yeahgis前辈没有很好地解决安全透明代码无法调用本机C++代码的问题,给每个类添加安全等级声明太麻烦了。通过查阅资料,把%gdal_code%swigcsharpAssemblyInfo.cs里的安全描述改为

    // The AllowPartiallyTrustedCallersAttribute requires the assembly to be signed with a strong name key.
    // This attribute is necessary since the control is called by either an intranet or Internet
    // Web page that should be running under restricted permissions.
    //[assembly: SecurityCritical]
    
    // Use the .NET Framework 2.0 transparency rules (level 1 transparency) as default
    #if (CLR4)
    [assembly: SecurityRules(SecurityRuleSet.Level2)]
    #endif

    就不会出现代码安全等级问题了。

      .NET的代码安全由[assembly: SecurityCritical]和[assembly: SecurityRules(SecurityRuleSet.Level2)]共同决定,程序集范围批注有NONE、SecurityTransparent、SecurityCritical、AllowPartiallyTrustedCallers四种特性,SecurityRuleSet有Level1、Level2两个级别,组合后的安全等级描述如下

    本次编译中我选择NONE、Level2,安全等级就够用了。

    附:代码访问安全性基础知识 https://msdn.microsoft.com/zh-cn/library/dd233102.aspx

  • 相关阅读:
    实习期收获(一)
    实习期上班两天感触
    做bbs论坛项目的收获(1)
    ios多线程
    C 预处理小结
    Xcode8 问题
    Unity3d收藏链接/ 小马哥视频
    H5(1)
    ios-loadView
    iOS开发UI篇—程序启动原理和UIApplication
  • 原文地址:https://www.cnblogs.com/sunnyeveryday/p/5011389.html
Copyright © 2020-2023  润新知