<html><head></head><body><div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:13px"><div dir="ltr" id="yui_3_16_0_1_1447674724388_3215"><br></div><div id="yui_3_16_0_1_1447674724388_3995" dir="ltr">Hello to IronPython community,<br><br>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?</div><div id="yui_3_16_0_1_1447674724388_3310" dir="ltr"><br></div><div id="yui_3_16_0_1_1447674724388_3327" dir="ltr">This is the code:</div><div id="yui_3_16_0_1_1447674724388_3993" dir="ltr"><br></div><pre class="" id="yui_3_16_0_1_1447674724388_3316"><font id="yui_3_16_0_1_1447674724388_3970" color="#440062"><code id="yui_3_16_0_1_1447674724388_3318" class=""><span id="yui_3_16_0_1_1447674724388_3320" class="">import</span> clr
clr.AddReferenceToFileAndPath(<span id="yui_3_16_0_1_1447674724388_3322" class="">"c:/gdal/gdal2bb/gdal_csharp.dll"</span>)

<span id="yui_3_16_0_1_1447674724388_3324" class="">import</span> OSGeo.GDAL <span id="yui_3_16_0_1_1447674724388_3326" class="">as</span> gdalc

gdalc.Gdal.AllRegister()</code></font><br><code id="yui_3_16_0_1_1447674724388_3318" class=""></code><code id="yui_3_16_0_1_1447674724388_3318" class=""><br></code><code id="yui_3_16_0_1_1447674724388_3318" class=""></code><code id="yui_3_16_0_1_1447674724388_3318" class=""><br><font face="verdana, helvetica, sans-serif">The last line raises:<br><br></font></code><font id="yui_3_16_0_1_1447674724388_3783" color="#440062" face="verdana, helvetica, sans-serif"><code id="yui_3_16_0_1_1447674724388_3376" class="">The <span id="yui_3_16_0_1_1447674724388_3378" class="">type</span> initializer <span id="yui_3_16_0_1_1447674724388_3380" class="">for</span> <span id="yui_3_16_0_1_1447674724388_3382" class="">'OSGeo.GDAL.GdalPINVOKE'</span> threw an exception.</code></font><br><font id="yui_3_16_0_1_1447674724388_3783" face="verdana, helvetica, sans-serif"><code id="yui_3_16_0_1_1447674724388_3376" class=""></code></font><font id="yui_3_16_0_1_1447674724388_3783" face="verdana, helvetica, sans-serif"><code id="yui_3_16_0_1_1447674724388_3376" class=""><br><br></code>I am essentially trying to open the file by replicating this <a class="" id="yui_3_16_0_1_1447674724388_3395" href="http://www.gdal.org/gdal_tutorial.html" rel="nofollow">c++ example</a>.<br id="yui_3_16_0_1_1447674724388_3622"><br id="yui_3_16_0_1_1447674724388_3620">What is the reason for the raised PINVOKE exception?<br id="yui_3_16_0_1_1447674724388_3618"><br id="yui_3_16_0_1_1447674724388_3616">I have a 32 bit windows XP SP3 operating system and loaded gdal_csharp.dll is 32 bit compiled, download​ed from <a class="" id="yui_3_16_0_1_1447674724388_3435" href="http://gisinternals.com/query.html?content=filelist&file=release-1600-gdal-1-11-1-mapserver-6-4-1.zip" rel="nofollow">gisinternals.com</a>. I <a class="" id="yui_3_16_0_1_1447674724388_3437" href="https://www.dropbox.com/s/lqtfe5ntp3ttslq/csharp_gdal.zip?dl=0" rel="nofollow">attached gdal_csharp.dll</a> and all other its .dlls in here. I am using IronPython 2.7, which is what <a id="yui_3_16_0_1_1447674724388_3610" class="edited-link-editor" href="http://www.rhino3d.com/">Rhino 5</a> application is shipped with (basically, I am using IronPython 2.7 interpreter inside Rhino 5 application).<br class="" id="yui_3_16_0_1_1447674724388_3439">This is the <a class="" id="yui_3_16_0_1_1447674724388_3441" href="http://www.gdal.org/gdal_8h.html" rel="nofollow">gdal documentation page</a>.<br><br>I tried looking for an answer at Gdal's mailing list too, but without success.<br><br>Any help would be appreciated.<br><br>Thank you in advance,<br><br>Kind regards,<br>Djordje Spasic</font><br></pre><div id="yui_3_16_0_1_1447674724388_3316"><br></div></div></body></html>