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

相关文章:

  • 2021-12-25
  • 2021-08-07
  • 2021-08-21
  • 2021-05-17
  • 2022-12-23
  • 2021-12-19
  • 2021-10-11
猜你喜欢
  • 2022-12-23
  • 2021-07-19
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案