以前一直用的是別人編譯好的gdal庫開發,今天本身編譯了gdal的2.0.0版本,踩了很多坑,但總算解決了。html
編譯方法主要參考http://blog.csdn.net/liminlu0314/article/details/6945452,踩到的坑及解決方法參考http://www.cnblogs.com/yeahgis/archive/2013/04/10/3011553.html。可是yeahgis前輩沒有很好地解決安全透明代碼沒法調用本機C++代碼的問題,給每一個類添加安全等級聲明太麻煩了。經過查閱資料,把%gdal_code%\swig\csharp\AssemblyInfo.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
就不會出現代碼安全等級問題了。ui
.NET的代碼安全由[assembly: SecurityCritical]和[assembly: SecurityRules(SecurityRuleSet.Level2)]共同決定,程序集範圍批註有NONE、SecurityTransparent、SecurityCritical、AllowPartiallyTrustedCallers四種特性,SecurityRuleSet有Level一、Level2兩個級別,組合後的安全等級描述以下spa
本次編譯中我選擇NONE、Level2,安全等級就夠用了。.net
附:代碼訪問安全性基礎知識 https://msdn.microsoft.com/zh-cn/library/dd233102.aspxrest