ThinkGeo.com    |     Documentation    |     Premium Support

The type initializer for 'ThinkGeo.Core.GdalRasterSource' threw an exception

Hello,
I’m trying to port a Framework 4.8 App to .Net Core 7. I added the same ThinkGeo NutGet Packages to my solution. The only difference is, that I now use the version 13.1 instead the 13.0 in my Framework App.

When I try to add an ecw or tiff Layer I get the exception: “The type initializer for ‘ThinkGeo.Core.GdalRasterSource’ threw an exception”. And the Stack trace has the following messages:

  • TypeInitializationException: The type initializer for ‘ThinkGeo.Core.GdalConfiguration’ threw an exception.
  • TypeInitializationException: The type initializer for ‘OSGeo.GDAL.GdalPINVOKE’ threw an exception.
  • TypeInitializationException: The type initializer for ‘SWIGExceptionHelper’ threw an exception.
  • DllNotFoundException: Unable to load DLL ‘gdal_wrap’ or one of its dependencies: Das angegebene Modul wurde nicht gefunden. (0x8007007E) (dll not found)

When I check the bin folders the Core App has no ‘gdaldata’ folder. And in the folders ‘…\runtimes\win-x86\native\’ or ‘…\runtimes\win-x64\native\’ there are no ‘gdalplugins’ folder an a lot of dll are also missing. (see the picture: left the Framework App – right the Core App.

Any suggestions?
Regards Torsten

Hi Torsten,

It’s good to hear from you again. I think you’re on the right track. Based on your stack trace and screenshot, the issue is the GDAL dependencies were not installed. In your screenshot, the Core app should have the same dependencies as the Framework app.

To resolve this, you can try the following:

  • in Nuget, Uninstall and Reinstall the ThinkGeo.Ecw package. Since this has a dependency of ThinkGeo.Gdal, which in turn depends on ThinkGeo.Dependency.Gdal it should reference both dependencies and hopefully you’ll have the gdalplugins folder.
  • If that doesn’t work, you can try to explicitly install ThinkGeo.Gdal and ThinkGeo.Dependency.Gdal from Nuget and see if that fixes things or not.

Good luck and let me know how it goes.

Thanks,
John

Hi John,
many thank’s for your suggestions. The problem disappiers, when the main project reference the ThinkGeo.Ecw package, not only the assembly where the package is realy needed.

Thanks,
Torsten

Hi @Torsten

I’m glad the problem is resolved. Good luck and let us know if you need anything in the future.

Thanks,
John