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

来源:互联网 发布:数据侠客行txt下载 编辑:程序博客网 时间:2024/05/23 12:52

之前写过一篇关于再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#的库,即可。

0 0
原创粉丝点击