[Python.NET] Re: Binary file passed to .Net object
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]
[Python.NET] Re: Binary file passed to .Net object
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 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]
[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 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 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
> 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]
>
___
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]
[Python.NET] Re: Binary file passed to .Net object
Can you try this from C# interactive (or plain C#)? #r "C:\Test_MW\Tools\GuiTest\ExamRecordHelper.dll"using ExamRecordHelper; var record = 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: AlexMSent: Wednesday, January 27, 2021 5:16 PMTo: A list for users and developers of Python.NETSubject: [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.pyLoad Exam RecordCould 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 clrtry: 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 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 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] unsubscribe send an email to [email protected]://mail.python.org/mailman3/lists/pythonnet.python.org/Member address: [email protected]___PythonNet mailing list -- [email protected] unsubscribe send an email to [email protected]://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]
