GDAL C#版本 "安全透明方法"問題解決方案

以前寫過一篇關於再C#中調用GDAL庫出現OSGeo.GDAL.GdalPINVOKE」的類型初始值設定項引起異常的解決方案,博客地址見下:
http://blog.csdn.net/liminlu0314/article/details/7506101安全

可是解決完該問題以後,還會出現下面的問題:
「安全透明方法「OSGeo.GDAL.Gdal.AllRegister()」嘗試經過方法「OSGeo.GDAL.GdalPINVOKE.AllRegister()」調用本機代碼失敗。方法必須是安全關鍵的或安全可靠關鍵的」markdown

要解決這個問題,須要在編譯GDAL的C#版本時,修改csharp目錄中的AssemblyInfo.cs文件。具體修改以下:ui

// 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: AllowPartiallyTrustedCallers] 註釋掉這一行

修改完成以後,從新生成C#的庫,便可。spa