[Ironpython-users] PINVOKE exception from loaded .NET assembly

Djordje Spasic issworld2000 at yahoo.com
Tue Nov 17 06:09:59 EST 2015


That worked perfectly and saved my day.

Thank you Markus!
Kind regards,
Djordje 


      From: Markus Schaber <m.schaber at codesys.com>
 To: Djordje Spasic <issworld2000 at yahoo.com>; "ironpython-users at python.org" <ironpython-users at python.org> 
 Sent: Tuesday, November 17, 2015 11:52 AM
 Subject: RE: [Ironpython-users] PINVOKE exception from loaded .NET assembly
   
#yiv0525296540 #yiv0525296540 -- _filtered #yiv0525296540 {font-family:Helvetica;panose-1:2 11 6 4 2 2 2 2 2 4;} _filtered #yiv0525296540 {font-family:Helvetica;panose-1:2 11 6 4 2 2 2 2 2 4;} _filtered #yiv0525296540 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv0525296540 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered #yiv0525296540 {font-family:Consolas;panose-1:2 11 6 9 2 2 4 3 2 4;} _filtered #yiv0525296540 {font-family:Verdana;panose-1:2 11 6 4 3 5 4 4 2 4;}#yiv0525296540 #yiv0525296540 p.yiv0525296540MsoNormal, #yiv0525296540 li.yiv0525296540MsoNormal, #yiv0525296540 div.yiv0525296540MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv0525296540 a:link, #yiv0525296540 span.yiv0525296540MsoHyperlink {color:blue;text-decoration:underline;}#yiv0525296540 a:visited, #yiv0525296540 span.yiv0525296540MsoHyperlinkFollowed {color:purple;text-decoration:underline;}#yiv0525296540 code {}#yiv0525296540 pre {margin:0cm;margin-bottom:.0001pt;font-size:10.0pt;}#yiv0525296540 p.yiv0525296540MsoAcetate, #yiv0525296540 li.yiv0525296540MsoAcetate, #yiv0525296540 div.yiv0525296540MsoAcetate {margin:0cm;margin-bottom:.0001pt;font-size:8.0pt;}#yiv0525296540 span.yiv0525296540HTMLVorformatiertZchn {font-family:Consolas;}#yiv0525296540 p.yiv0525296540msoacetate, #yiv0525296540 li.yiv0525296540msoacetate, #yiv0525296540 div.yiv0525296540msoacetate {margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv0525296540 p.yiv0525296540msonormal, #yiv0525296540 li.yiv0525296540msonormal, #yiv0525296540 div.yiv0525296540msonormal {margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv0525296540 p.yiv0525296540msochpdefault, #yiv0525296540 li.yiv0525296540msochpdefault, #yiv0525296540 div.yiv0525296540msochpdefault {margin-right:0cm;margin-left:0cm;font-size:12.0pt;}#yiv0525296540 span.yiv0525296540msohyperlink {}#yiv0525296540 span.yiv0525296540msohyperlinkfollowed {}#yiv0525296540 span.yiv0525296540htmlvorformatiertzchn {}#yiv0525296540 span.yiv0525296540e-mailformatvorlage20 {}#yiv0525296540 p.yiv0525296540msonormal1, #yiv0525296540 li.yiv0525296540msonormal1, #yiv0525296540 div.yiv0525296540msonormal1 {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv0525296540 span.yiv0525296540msohyperlink1 {color:blue;text-decoration:underline;}#yiv0525296540 span.yiv0525296540msohyperlinkfollowed1 {color:purple;text-decoration:underline;}#yiv0525296540 p.yiv0525296540msoacetate1, #yiv0525296540 li.yiv0525296540msoacetate1, #yiv0525296540 div.yiv0525296540msoacetate1 {margin:0cm;margin-bottom:.0001pt;font-size:8.0pt;}#yiv0525296540 span.yiv0525296540htmlvorformatiertzchn1 {font-family:Consolas;}#yiv0525296540 span.yiv0525296540e-mailformatvorlage201 {color:windowtext;font-weight:normal;font-style:normal;}#yiv0525296540 p.yiv0525296540msochpdefault1, #yiv0525296540 li.yiv0525296540msochpdefault1, #yiv0525296540 div.yiv0525296540msochpdefault1 {margin-right:0cm;margin-left:0cm;font-size:10.0pt;}#yiv0525296540 span.yiv0525296540E-MailFormatvorlage34 {color:windowtext;font-weight:normal;font-style:normal;}#yiv0525296540 span.yiv0525296540SprechblasentextZchn {}#yiv0525296540 .yiv0525296540MsoChpDefault {font-size:10.0pt;} _filtered #yiv0525296540 {margin:70.85pt 70.85pt 2.0cm 70.85pt;}#yiv0525296540 div.yiv0525296540WordSection1 {}#yiv0525296540 Hi,    it seems, in your case, it’s not an aggregate exception, so you just need to access the InnerException property (without an „s“ at the end) of your System.Exception    Best regards

Markus Schaber

CODESYS®a trademark of 3S-Smart Software Solutions GmbH

Inspiring Automation Solutions 3S-Smart Software Solutions GmbH
Dipl.-Inf. Markus Schaber | Product Development Core Technology 
Memminger Str. 151 | 87439 Kempten | Germany 
Tel. +49-831-54031-979 | Fax +49-831-54031-50 

E-Mail: m.schaber at codesys.com | Web: codesys.com | CODESYS store: store.codesys.com
CODESYS forum: forum.codesys.com

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915 This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received
this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure
or distribution of the material in this e-mail is strictly forbidden. 

From: Djordje Spasic [mailto:issworld2000 at yahoo.com]
Sent: Tuesday, November 17, 2015 11:46 AM
To: Markus Schaber; ironpython-users at python.org
Subject: Re: [Ironpython-users] PINVOKE exception from loaded .NET assembly    Thank you.

I am not a programmer myself.
How would either InnerException or AggregateException be used in this case? I tried: try:   
 gdalc.Gdal.AllRegister()
except System.AggregateException as e:
    print "exception: ", e.InnerExceptions  

    But that didn't seem to be correct.

 From: Markus Schaber <m.schaber at codesys.com>
To: Djordje Spasic <issworld2000 at yahoo.com>; "ironpython-users at python.org" <ironpython-users at python.org>
Sent: Tuesday, November 17, 2015 11:31 AM
Subject: RE: [Ironpython-users] PINVOKE exception from loaded .NET assembly    Hi,   The inner exception (if present) can be accessed via the InnerException property of the “outer” exception:   https://msdn.microsoft.com/de-de/library/system.exception.innerexception%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396   (This is a .NET feature, not an IronPython specific one.)   There’s also an AggregateException which is used in some cases: https://msdn.microsoft.com/de-de/library/system.aggregateexception%28v=vs.110%29.aspx     Grüße, Markus      From: Djordje Spasic [mailto:issworld2000 at yahoo.com]
Sent: Tuesday, November 17, 2015 11:16 AM
To: Markus Schaber; ironpython-users at python.org
Subject: Re: [Ironpython-users] PINVOKE exception from loaded .NET assembly   Hi Markus,

Thank you for the reply. How can I access the inner exception in ironpython?

I tried this:   import clr clr.AddReferenceToFileAndPath("c:/gdal/gdal2bb/gdal_csharp.dll")    import OSGeo.GDAL as gdalc    try:
    gdalc.Gdal.AllRegister()

except System.Exception as e:
    print e.Message   But it raises the same message:   The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception. 
So this is not an inner exception?       Regards,
Djordje   From: Markus Schaber <m.schaber at codesys.com>
To: Djordje Spasic <issworld2000 at yahoo.com>
Sent: Tuesday, November 17, 2015 7:57 AM
Subject: RE: [Ironpython-users] PINVOKE exception from loaded .NET assembly 
Hello,

From: Djordje    

> 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? 

Maybe you could try to access the inner exception?

Best regards

Markus Schaber

CODESYS® a trademark of 3S-Smart Software Solutions GmbH 

Inspiring Automation Solutions 
________________________________________
3S-Smart Software Solutions GmbH 
Dipl.-Inf. Markus Schaber | Product Development Core Technology 
Memminger Str. 151 | 87439 Kempten | Germany 
Tel. +49-831-54031-979 | Fax +49-831-54031-50 

E-Mail: m.schaber at codesys.com | Web: codesys.com | CODESYS store: store.codesys.com
CODESYS forum: forum.codesys.com 

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915
________________________________________
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received
this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure
or distribution of the material in this e-mail is strictly forbidden.         

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20151117/2e02d5fd/attachment.html>


More information about the Ironpython-users mailing list