[Python.NET] Re: Binary file passed to .Net object

AlexM <[email protected]> Thu, 28 Jan 2021 08:05:11 -0500
Newsgroups gmane.comp.python.dotnet
Message-ID <CAHgbZ6ALmCwkM1_kGoEC8sTjADNKEgppx+7i7MaqBZDQuu8teA@mail.gmail.com>
--===============4882389068339247166==
Content-Type: multipart/alternative; boundary="0000000000004efaf805b9f58aea"

--0000000000004efaf805b9f58aea
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I have uploaded the dlls and sources to the dropbox, Victor. Check your
email(  [email protected] )

On Wed, Jan 27, 2021 at 8:27 PM Victor =E2=80=9CLOST=E2=80=9D Milovanov <
[email protected]> wrote:

> Can you try this from C# interactive (or plain C#)?
>
>
>
> #r "C:\Test_MW\Tools\GuiTest\ExamRecordHelper.dll"
>
> using ExamRecordHelper;
>
>
>
> var record =3D new
> ExamRecordLoader("C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT");
>
>
>
> Without having ExamRecordHelper.dll, it is hard to guess otherwise, but I
> agree with Manu, this looks like a mistake in the code (different files
> and/or different versions of the DLL being loaded).
>
>
>
> Regards,
>
> Victor
>
>
>
> *From: *AlexM <[email protected]>
> *Sent: *Wednesday, January 27, 2021 5:16 PM
> *To: *A list for users and developers of Python.NET <[email protected]=
>
> *Subject: *[Python.NET] Re: Binary file passed to .Net object
>
>
>
> 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 DataTyp=
e.
>    at ExamRecordHelper.ExamRecordLoader.LoadExamRecord(String filename)
>    at ExamRecordHelper.ExamRecordLoader..ctor(String filename)
>
>
>
> And this is the source:
>
>
>
> import clr
> try:
>     ExRHelperAsseblyRef =3D
> clr.AddReference("C:\\Test_MW\\Tools\\GuiTest\\ExamRecordHelper.dll")
>     from ExamRecordHelper import *
>
> except Exception, e:
>     print("Exception : " + str(e))
>
>
>
> # path to binary file:
> examRecordFile =3D r'C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT'
>
> try:
>     print "Load Exam Record"
>     exrec =3D ExamRecordLoader(examRecordFile) # <<<<<<<<<<<<<<<<<<<<<
> Exception line
>     stepList=3Dexrec.GetStepList()
>     print "stepList=3D"+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 =3D
> 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]
>
>
> _______________________________________________
> 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]
>

--0000000000004efaf805b9f58aea
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I have uploaded the dlls and sources to the dropbox, Victo=
r. Check your email(=C2=A0<h3 class=3D"gmail-iw" style=3D"overflow:hidden;w=
hite-space:nowrap;font-size:0.75rem;font-weight:inherit;margin:inherit;text=
-overflow:ellipsis;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-seri=
f;letter-spacing:0.3px;color:rgb(95,99,104);line-height:20px"><span class=
=3D"gmail-qu" tabindex=3D"-1" style=3D"outline:none">=C2=A0<span class=3D"g=
mail-go" style=3D"vertical-align:top;color:rgb(85,85,85)"><a href=3D"mailto=
:[email protected]">[email protected]</a> )</span></span></h3></div=
><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On We=
d, Jan 27, 2021 at 8:27 PM Victor =E2=80=9CLOST=E2=80=9D Milovanov &lt;<a h=
ref=3D"mailto:[email protected]">[email protected]</a>&gt; wrote:<b=
r></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 lang=3D"EN-U=
S" style=3D"overflow-wrap: break-word;"><div class=3D"gmail-m_4151227316724=
333964WordSection1"><p class=3D"MsoNormal">Can you try this from C# interac=
tive (or plain C#)?</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p cl=
ass=3D"MsoNormal">#r &quot;C:\Test_MW\Tools\GuiTest\ExamRecordHelper.dll&qu=
ot;</p><p class=3D"MsoNormal">using ExamRecordHelper;</p><p class=3D"MsoNor=
mal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">var record =3D new Exam=
RecordLoader(&quot;C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT&quot;);</p><p =
class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">Without =
having ExamRecordHelper.dll, it is hard to guess otherwise, but I agree wit=
h Manu, this looks like a mistake in the code (different files and/or diffe=
rent versions of the DLL being loaded).</p><p class=3D"MsoNormal"><u></u>=
=C2=A0<u></u></p><p class=3D"MsoNormal">Regards,</p><p class=3D"MsoNormal">=
Victor</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><div style=3D"bord=
er-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(=
225,225,225);padding:3pt 0in 0in"><p class=3D"MsoNormal" style=3D"border:no=
ne;padding:0in"><b>From: </b><a href=3D"mailto:[email protected]" target=
=3D"_blank">AlexM</a><br><b>Sent: </b>Wednesday, January 27, 2021 5:16 PM<b=
r><b>To: </b><a href=3D"mailto:[email protected]" target=3D"_blank">A li=
st for users and developers of Python.NET</a><br><b>Subject: </b>[Python.NE=
T] Re: Binary file passed to .Net object</p></div><p class=3D"MsoNormal"><u=
></u>=C2=A0<u></u></p><div><p class=3D"MsoNormal">Manu, thank you very much=
 for your suggestions...</p><div><p class=3D"MsoNormal">So, far I have .dll=
 and these are not the solutions.</p></div><div><p class=3D"MsoNormal">Also=
, the exact same code works in IronPython, b.t.w.....</p></div><div><p clas=
s=3D"MsoNormal"><u></u>=C2=A0<u></u></p><div><p class=3D"MsoNormal">Well, t=
he error does come from the &quot;ExamRecordLoader&quot;, here is the outpu=
t:</p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div>=
<p class=3D"MsoNormal">c:\Test_MW\Tools\GuiTest&gt;python getExamRecord.py<=
br>Load Exam Record<br>Could not load Exam Record: =C2=A0Error loading Exam=
Record binary file: C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT Column requir=
es a valid DataType.<br>=C2=A0 =C2=A0at ExamRecordHelper.ExamRecordLoader.L=
oadExamRecord(String filename)<br>=C2=A0 =C2=A0at ExamRecordHelper.ExamReco=
rdLoader..ctor(String filename)</p></div><div><p class=3D"MsoNormal"><u></u=
>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal">And this is the source:=
</p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p=
 class=3D"MsoNormal">import clr<br>try:<br>=C2=A0 =C2=A0 ExRHelperAsseblyRe=
f =3D clr.AddReference(&quot;C:\\Test_MW\\Tools\\GuiTest\\ExamRecordHelper.=
dll&quot;)<br>=C2=A0 =C2=A0 from ExamRecordHelper import *<br><br>except Ex=
ception, e:<br>=C2=A0 =C2=A0 print(&quot;Exception : &quot; + str(e))</p></=
div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p class=
=3D"MsoNormal"># path to binary file:<br>examRecordFile =3D r&#39;C:\\Test_=
MW\\Tools\\ExamRecords\\Resp4DCT&#39;<br><br>try:<br>=C2=A0 =C2=A0 print &q=
uot;Load Exam Record&quot;<br>=C2=A0 =C2=A0 exrec =3D ExamRecordLoader(exam=
RecordFile) # &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&=
lt;&lt;&lt;&lt;&lt;&lt; Exception line <br>=C2=A0 =C2=A0 stepList=3Dexrec.G=
etStepList()<br>=C2=A0 =C2=A0 print &quot;stepList=3D&quot;+str(stepList)<b=
r>except Exception as e:<br>=C2=A0 =C2=A0 print &quot;Could not load Exam R=
ecord: &quot;, str(e)</p></div></div><div><p class=3D"MsoNormal"><u></u>=C2=
=A0<u></u></p></div><div><p class=3D"MsoNormal">Alex.</p></div></div><p cla=
ss=3D"MsoNormal"><u></u>=C2=A0<u></u></p><div><div><p class=3D"MsoNormal">O=
n Wed, Jan 27, 2021 at 3:54 PM Emmanuel Rutovic &lt;[email protected]&gt; wro=
te:</p></div><blockquote style=3D"border-top:none;border-right:none;border-=
bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;=
margin-left:4.8pt;margin-right:0in"><div><div><div><div><div><div><div><p c=
lass=3D"MsoNormal">Hi Alex,</p></div><div><p class=3D"MsoNormal"><u></u>=C2=
=A0<u></u></p></div><div><p class=3D"MsoNormal">It seems that the=C2=A0exce=
ption is thrown inside your method &quot;ExamRecordLoader&quot; so it is ha=
rd to debug.=C2=A0</p></div><div><p class=3D"MsoNormal">Is it possible that=
 the error is thrown because of different working directories? Can you try =
to use the full path to &#39;MyBinaryFile.bin&#39; ?</p></div><div><p class=
=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal">Al=
so, I always use the file name including the extension ( clr.AddReference(&=
quot;C:\ExamRecordHelper<b>.dll</b>&quot;) ) but I doubt it will change any=
thing</p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><d=
iv><p class=3D"MsoNormal">I hope it helps,</p></div><div><p class=3D"MsoNor=
mal">Manu.=C2=A0</p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u><=
/p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div></div></=
div></div></div></div></div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p>=
<div><div><p class=3D"MsoNormal">On Wed, Jan 27, 2021 at 2:47 PM Alexander =
Masis &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">alexmasi=
[email protected]</a>&gt; wrote:</p></div><blockquote style=3D"border-top:none;bo=
rder-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);p=
adding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in"><p class=3D"MsoN=
ormal">The code in the original post works in IronPython ( i.e. loaderObj =
=3D ExamRecordLoader( &#39;MyBinaryFile.bin&#39;) this line has no exceptio=
ns in IronPython )<br>_______________________________________________<br>Py=
thonNet 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]" target=3D"_blank">pythonnet-leave@py=
thon.org</a><br><a href=3D"https://mail.python.org/mailman3/lists/pythonnet=
.python.org/" target=3D"_blank">https://mail.python.org/mailman3/lists/pyth=
onnet.python.org/</a><br>Member address: [email protected]</p></blockquote></=
div></blockquote></div><p class=3D"MsoNormal" style=3D"margin-left:4.8pt">_=
______________________________________________<br>PythonNet mailing list --=
 <a href=3D"mailto:[email protected]" target=3D"_blank">pythonnet@python=
.org</a><br>To unsubscribe send an email to <a href=3D"mailto:pythonnet-lea=
[email protected]" target=3D"_blank">[email protected]</a><br><a href=
=3D"https://mail.python.org/mailman3/lists/pythonnet.python.org/" target=3D=
"_blank">https://mail.python.org/mailman3/lists/pythonnet.python.org/</a><b=
r>Member address: <a href=3D"mailto:[email protected]" target=3D"_blank">=
[email protected]</a></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><=
/div></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>

--0000000000004efaf805b9f58aea--

--===============4882389068339247166==
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]

--===============4882389068339247166==--