[Python.NET] Re: Binary file passed to .Net object
AlexM <[email protected]> Wed, 27 Jan 2021 18:58:12 -0500
| Newsgroups | gmane.comp.python.dotnet |
|---|---|
| Message-ID | <CAHgbZ6C96Hdt9cKXZ+WfLejid0mLFG3HmyRBZAYkN5DOR1k90w@mail.gmail.com> |
--===============9170435630554233169==
Content-Type: multipart/alternative; boundary="000000000000dfd65005b9ea8bf5"
--000000000000dfd65005b9ea8bf5
Content-Type: text/plain; charset="UTF-8"
Manu, thank you very much for your suggestions...
So, far I have .dll and these are not the solutions.
Also, the exact same code works in IronPython, b.t.w.....
Well, the error does come from the "ExamRecordLoader", here is the output:
c:\Test_MW\Tools\GuiTest>python getExamRecord.py
Load Exam Record
Could not load Exam Record: Error loading ExamRecord binary file:
C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT Column requires a valid DataType.
at ExamRecordHelper.ExamRecordLoader.LoadExamRecord(String filename)
at ExamRecordHelper.ExamRecordLoader..ctor(String filename)
And this is the source:
import clr
try:
ExRHelperAsseblyRef =
clr.AddReference("C:\\Test_MW\\Tools\\GuiTest\\ExamRecordHelper.dll")
from ExamRecordHelper import *
except Exception, e:
print("Exception : " + str(e))
# path to binary file:
examRecordFile = r'C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT'
try:
print "Load Exam Record"
exrec = ExamRecordLoader(examRecordFile) # <<<<<<<<<<<<<<<<<<<<<
Exception line
stepList=exrec.GetStepList()
print "stepList="+str(stepList)
except Exception as e:
print "Could not load Exam Record: ", str(e)
Alex.
On Wed, Jan 27, 2021 at 3:54 PM Emmanuel Rutovic <[email protected]> wrote:
> Hi Alex,
>
> It seems that the exception is thrown inside your method
> "ExamRecordLoader" so it is hard to debug.
> Is it possible that the error is thrown because of different working
> directories? Can you try to use the full path to 'MyBinaryFile.bin' ?
>
> Also, I always use the file name including the extension (
> clr.AddReference("C:\ExamRecordHelper*.dll*") ) but I doubt it will
> change anything
>
> I hope it helps,
> Manu.
>
>
>
> On Wed, Jan 27, 2021 at 2:47 PM Alexander Masis <[email protected]>
> wrote:
>
>> The code in the original post works in IronPython ( i.e. loaderObj =
>> ExamRecordLoader( 'MyBinaryFile.bin') this line has no exceptions in
>> IronPython )
>> _______________________________________________
>> PythonNet mailing list -- [email protected]
>> To unsubscribe send an email to [email protected]
>> https://mail.python.org/mailman3/lists/pythonnet.python.org/
>> Member address: [email protected]
>>
> _______________________________________________
> PythonNet mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/pythonnet.python.org/
> Member address: [email protected]
>
--000000000000dfd65005b9ea8bf5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Manu, thank you very much for your suggestions...<div>So, =
far I have .dll and these are not the solutions.</div><div>Also, the exact =
same code works in IronPython, b.t.w.....</div><div><br><div>Well, the erro=
r does come from the "ExamRecordLoader", here is the output:</div=
><div><br></div><div>c:\Test_MW\Tools\GuiTest>python getExamRecord.py<br=
>Load Exam Record<br>Could not load Exam Record: =C2=A0Error loading ExamRe=
cord binary file: C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT Column requires=
a valid DataType.<br>=C2=A0 =C2=A0at ExamRecordHelper.ExamRecordLoader.Loa=
dExamRecord(String filename)<br>=C2=A0 =C2=A0at ExamRecordHelper.ExamRecord=
Loader..ctor(String filename)<br></div><div><br></div><div>And this is the =
source:</div><div><br></div><div>import clr<br>try:<br>=C2=A0 =C2=A0 ExRHel=
perAsseblyRef =3D clr.AddReference("C:\\Test_MW\\Tools\\GuiTest\\ExamR=
ecordHelper.dll")<br>=C2=A0 =C2=A0 from ExamRecordHelper import *<br><=
br>except Exception, e:<br>=C2=A0 =C2=A0 print("Exception : " + s=
tr(e))</div><div><br></div><div># path to binary file:<br>examRecordFile =
=3D r'C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT'<br><br>try:<br>=C2=
=A0 =C2=A0 print "Load Exam Record"<br>=C2=A0 =C2=A0 exrec =3D Ex=
amRecordLoader(examRecordFile) # <<<<<<<<<<&l=
t;<<<<<<<<<< Exception line <br>=C2=A0 =C2=A0=
stepList=3Dexrec.GetStepList()<br>=C2=A0 =C2=A0 print "stepList=3D&qu=
ot;+str(stepList)<br>except Exception as e:<br>=C2=A0 =C2=A0 print "Co=
uld not load Exam Record: ", str(e)<br></div></div><div><br></div><div=
>Alex.</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"=
gmail_attr">On Wed, Jan 27, 2021 at 3:54 PM Emmanuel Rutovic <manu@aesim=
.tech> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin=
:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"=
><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div d=
ir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Hi Alex,</div><div dir=3D"ltr"=
><br></div><div dir=3D"ltr">It seems that the=C2=A0exception is thrown insi=
de your method "ExamRecordLoader" so it is hard to debug.=C2=A0</=
div><div dir=3D"ltr">Is it possible that the error is thrown because of dif=
ferent working directories? Can you try to use the full path to 'MyBina=
ryFile.bin' ?</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">Also, I =
always use the file name including the extension ( clr.AddReference("C=
:\ExamRecordHelper<b>.dll</b>") ) but I doubt it will change anything<=
br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">I hope it helps,<br></=
div><div>Manu.=C2=A0</div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br><=
/div></div></div></div></div></div></div><br><div class=3D"gmail_quote"><di=
v dir=3D"ltr" class=3D"gmail_attr">On Wed, Jan 27, 2021 at 2:47 PM Alexande=
r Masis <<a href=3D"mailto:[email protected]" target=3D"_blank">alexma=
[email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi=
ng-left:1ex">The code in the original post works in IronPython ( i.e. loade=
rObj =3D ExamRecordLoader( 'MyBinaryFile.bin') this line has no exc=
eptions in IronPython )<br>
_______________________________________________<br>
PythonNet mailing list -- <a href=3D"mailto:[email protected]" target=3D=
"_blank">[email protected]</a><br>
To unsubscribe send an email to <a href=3D"mailto:[email protected]=
g" target=3D"_blank">[email protected]</a><br>
<a href=3D"https://mail.python.org/mailman3/lists/pythonnet.python.org/" re=
l=3D"noreferrer" target=3D"_blank">https://mail.python.org/mailman3/lists/p=
ythonnet.python.org/</a><br>
Member address: [email protected]<br>
</blockquote></div>
_______________________________________________<br>
PythonNet mailing list -- <a href=3D"mailto:[email protected]" target=3D=
"_blank">[email protected]</a><br>
To unsubscribe send an email to <a href=3D"mailto:[email protected]=
g" target=3D"_blank">[email protected]</a><br>
<a href=3D"https://mail.python.org/mailman3/lists/pythonnet.python.org/" re=
l=3D"noreferrer" target=3D"_blank">https://mail.python.org/mailman3/lists/p=
ythonnet.python.org/</a><br>
Member address: <a href=3D"mailto:[email protected]" target=3D"_blank">al=
[email protected]</a><br>
</blockquote></div>
--000000000000dfd65005b9ea8bf5--
--===============9170435630554233169==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
PythonNet mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pythonnet.python.org/
Member address: [email protected]
--===============9170435630554233169==--