Hi @Alain, @dale, @stevebaer, @will
I am trying call a method from loaded .NET assembly in python, but for some reason, I am getting a PINVOKE exception. Is there some way to print what is the reason for that exception? This looks like a similar topic, but I am not sure how it can be replicated in ironpython.
This is the code:
import clr
clr.AddReferenceToFileAndPath("c:/gdal/gdal2bb/gdal_csharp.dll")
import OSGeo.GDAL as gdalc
gdalc.Gdal.AllRegister()
Last line raises:
The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception.
I am essentially trying to open the file by replicating this c++ example:
#include "gdal_priv.h"
#include "cpl_conv.h" // for CPLMalloc()
int main()
{
GDALDataset *poDataset;
GDALAllRegister();
poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );
if( poDataset == NULL )
{
...;
}
What is the reason for the raised PINVOKE exception?
Dale showed me how to check whether or not the loaded assembly is .NET or not. And it is. Further more the following code prints: True:
importedAssembly = "gdal_csharp" in [assembly.GetName().Name for assembly in clr.References]
print "importedAssembly: ", importedAssembly # prints: True
I have a 32 bit windows XP SP3 operating system and loaded gdal_csharp.dll is 32 bit compiled, download​ed from gisinternals.com. I attached gdal_csharp.dll and all other its .dlls in here. I am using Rhino 5 (5.12.50810.13095, 08/10/2015).
This is the gdal documentation page.
I contacted gdal mailing list, and got a reply, that this might be something related with Rhino, not with .NET assemblies.
Any help would be appreciated.
Thank you.