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

AlexM <[email protected]> Thu, 28 Jan 2021 07:51:40 -0500
Newsgroups gmane.comp.python.dotnet
Message-ID <CAHgbZ6BHMa3ZsTz=A10rFPwWz+zpJZNr8pmb8wQmFnjQ0H2qXA@mail.gmail.com>
--===============1675937628421275707==
Content-Type: multipart/alternative; boundary="00000000000001b9f905b9f55af9"

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

Victor, thanks for your response.
I did try a simple C# test code and it's working as expected.
So, both C# and IronPython calls work, but I still need Python.Net  to work=
.
Alex,
=D0=A1=D0=BF=D0=B0=D1=81=D0=B8=D0=B1=D0=BE..

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

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

<div dir=3D"ltr">Victor, thanks for your response.<div>I did try a simple C=
# test code and it&#39;s working as expected.=C2=A0</div><div>So, both C# a=
nd IronPython calls work, but I still need Python.Net=C2=A0 to work.</div><=
div>Alex,</div><div>=D0=A1=D0=BF=D0=B0=D1=81=D0=B8=D0=B1=D0=BE..<br></div><=
/div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">O=
n Wed, Jan 27, 2021 at 8:27 PM Victor =E2=80=9CLOST=E2=80=9D Milovanov &lt;=
<a href=3D"mailto:[email protected]" target=3D"_blank">lostfreeman@gmai=
l.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:=
1ex"><div lang=3D"EN-US"><div><p class=3D"MsoNormal">Can you try this from =
C# interactive (or plain C#)?</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u=
></p><p class=3D"MsoNormal">#r &quot;C:\Test_MW\Tools\GuiTest\ExamRecordHel=
per.dll&quot;</p><p class=3D"MsoNormal">using ExamRecordHelper;</p><p class=
=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">var record =
=3D new ExamRecordLoader(&quot;C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT&qu=
ot;);</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNorm=
al">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).</p><p class=3D"MsoNorma=
l"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">Regards,</p><p class=3D"M=
soNormal">Victor</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><div sty=
le=3D"border-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:none;padding:0in"><b>From: </b><a href=3D"mailto:[email protected]=
m" target=3D"_blank">AlexM</a><br><b>Sent: </b>Wednesday, January 27, 2021 =
5:16 PM<br><b>To: </b><a href=3D"mailto:[email protected]" target=3D"_bl=
ank">A list for users and developers of Python.NET</a><br><b>Subject: </b>[=
Python.NET] Re: Binary file passed to .Net object</p></div><p class=3D"MsoN=
ormal"><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"MsoNor=
mal">Also, the exact same code works in IronPython, b.t.w.....</p></div><di=
v><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><div><p class=3D"MsoNormal=
">Well, the error does come from the &quot;ExamRecordLoader&quot;, here is =
the output:</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 getExamR=
ecord.py<br>Load Exam Record<br>Could not load Exam Record: =C2=A0Error loa=
ding ExamRecord binary file: C:\\Test_MW\\Tools\\ExamRecords\\Resp4DCT Colu=
mn requires a valid DataType.<br>=C2=A0 =C2=A0at ExamRecordHelper.ExamRecor=
dLoader.LoadExamRecord(String filename)<br>=C2=A0 =C2=A0at ExamRecordHelper=
.ExamRecordLoader..ctor(String filename)</p></div><div><p class=3D"MsoNorma=
l"><u></u>=C2=A0<u></u></p></div><div><p class=3D"MsoNormal">And this is th=
e source:</p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></di=
v><div><p class=3D"MsoNormal">import clr<br>try:<br>=C2=A0 =C2=A0 ExRHelper=
AsseblyRef =3D clr.AddReference(&quot;C:\\Test_MW\\Tools\\GuiTest\\ExamReco=
rdHelper.dll&quot;)<br>=C2=A0 =C2=A0 from ExamRecordHelper import *<br><br>=
except Exception, 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 &quot;Load Exam Record&quot;<br>=C2=A0 =C2=A0 exrec =3D ExamRecordLo=
ader(examRecordFile) # &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.GetStepList()<br>=C2=A0 =C2=A0 print &quot;stepList=3D&quot;+str(s=
tepList)<br>except Exception as e:<br>=C2=A0 =C2=A0 print &quot;Could not l=
oad Exam Record: &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 class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><div><div><p class=3D"Ms=
oNormal">On Wed, Jan 27, 2021 at 3:54 PM Emmanuel Rutovic &lt;[email protected]=
ch&gt; wrote:</p></div><blockquote style=3D"border-top:none;border-right:no=
ne;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0i=
n 0in 6pt;margin-left:4.8pt;margin-right:0in"><div><div><div><div><div><div=
><div><p class=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=A0exception is thrown inside your method &quot;ExamRecordLoader&quot; s=
o it is hard to debug.=C2=A0</p></div><div><p class=3D"MsoNormal">Is it pos=
sible that the error is thrown because of different working directories? Ca=
n you try to use the full path to &#39;MyBinaryFile.bin&#39; ?</p></div><di=
v><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div><div><p class=3D"Mso=
Normal">Also, I always use the file name including the extension ( clr.AddR=
eference(&quot;C:\ExamRecordHelper<b>.dll</b>&quot;) ) but I doubt it will =
change anything</p></div><div><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></=
p></div><div><p class=3D"MsoNormal">I hope it helps,</p></div><div><p class=
=3D"MsoNormal">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></d=
iv></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"_blan=
k">[email protected]</a>&gt; wrote:</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"><p cl=
ass=3D"MsoNormal">The code in the original post works in IronPython ( i.e. =
loaderObj =3D ExamRecordLoader( &#39;MyBinaryFile.bin&#39;) this line has n=
o exceptions in IronPython )<br>___________________________________________=
____<br>PythonNet mailing list -- <a href=3D"mailto:[email protected]" t=
arget=3D"_blank">[email protected]</a><br>To unsubscribe send an email t=
o <a href=3D"mailto:[email protected]" target=3D"_blank">pythonnet=
[email protected]</a><br><a href=3D"https://mail.python.org/mailman3/lists/=
pythonnet.python.org/" target=3D"_blank">https://mail.python.org/mailman3/l=
ists/pythonnet.python.org/</a><br>Member address: [email protected]</p></bloc=
kquote></div></blockquote></div><p class=3D"MsoNormal" style=3D"margin-left=
:4.8pt">_______________________________________________<br>PythonNet mailin=
g list -- <a href=3D"mailto:[email protected]" target=3D"_blank">pythonn=
[email protected]</a><br>To unsubscribe send an email to <a href=3D"mailto:pyth=
[email protected]" target=3D"_blank">[email protected]</a><br=
><a href=3D"https://mail.python.org/mailman3/lists/pythonnet.python.org/" t=
arget=3D"_blank">https://mail.python.org/mailman3/lists/pythonnet.python.or=
g/</a><br>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>

--00000000000001b9f905b9f55af9--

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

--===============1675937628421275707==--