GDAL C#版本 "安全透明方法"问题解决方案

之前写过一篇关于再C#中调用GDAL库出现OSGeo.GDAL.GdalPINVOKE”的类型初始值设定项引发异常的解决方案,博客地址见下:
http://blog.csdn.net/liminlu0314/article/details/7506101

但是解决完该问题之后,还会出现下面的问题:
“安全透明方法“OSGeo.GDAL.Gdal.AllRegister()”尝试通过方法“OSGeo.GDAL.GdalPINVOKE.AllRegister()”调用本机代码失败。方法必须是安全关键的或安全可靠关键的”

要解决这个问题,需要在编译GDAL的C#版本时,修改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: AllowPartiallyTrustedCallers] 注释掉这一行

修改完成之后,重新生成C#的库,即可。

posted on 2017-01-05 11:28  王大王  阅读(442)  评论(0编辑  收藏  举报

导航