简体   繁体   English

IronPython不适用于Python 2.7和3.3

[英]IronPython Crash NOT for Python 2.7 and 3.3

I have no idea why the Ironpython crash after executing DLL but NOT python 2.7 and 3.3 我不知道为什么在执行DLL后Ironpython崩溃,但没有python 2.7和3.3

My code as below 我的代码如下

import ctypes
import time
DLLHANDLE=ctypes.cdll.LoadLibrary("C:\\INSTRDLL\\builds\\DCSOURCEDLL\\B2902A.dll")
INPUTSCRIPT="SYSTEM{DCSOURCE1|INIT}"
INPUTVOLTAGE=0.0
SOURCEHANDLE=DLLHANDLE.DCSOURCE(c_INPUTSCRIPT,c_INPUTVOLTAGE)
time.sleep(1)

Basically, The DLL is calling instrument to perform initialization once INPUTSCRIPT is issued. 基本上,一旦发出INPUTSCRIPT ,DLL就会调用仪器执行初始化。

I have attached the Crash screenshot. 我已附上Crash屏幕截图。 Please help... 请帮忙...

在此处输入图片说明

ctypes , in general, is a whole pile of whatever the opposite of fun is. 通常, ctypes是一堆有趣的东西,而与乐趣相反。 With normal Python, it's like coding in C - watch your pointers, data types, etc. - but at least CPython is relatively close to C and it works acceptably (it also the advantage of being much more widely used). 对于普通的Python,这就像用C进行编码-观察指针,数据类型等-但至少CPython与C相对较近,并且可以正常工作(这也是使用更广泛的优势)。

In IronPython, it's that, plus the CLR has to intermediate everything - it uses the .NET marshaling APIs, and also generates P/Invoke declarations at runtime. 在IronPython中,就是这样,加上CLR必须对所有内容进行中间处理-它使用.NET封送处理API,并且还在运行时生成P / Invoke声明。 The code to do this is rather complicated and has known bugs - dealing with raw memory is not what .NET is designed to do! 执行此操作的代码相当复杂,并且具有已知的错误-处理原始内存不是.NET设计的目的!

One area of concern is that IronPython uses Unicode strings, while you don't specify what type the DCSOURCE function takes (wide/Unicode/ wchar_t* or narrow/ANSI/ char* ). 一个令人关注的领域是IronPython使用Unicode字符串,而您没有指定DCSOURCE函数采用的类型(宽/ Unicode / wchar_t*或窄/ ANSI / char* )。 Without knowing the signature of the C function it's hard to say. 在不知道C函数签名的情况下,很难说。 I also don't remember what IronPython ctypes assumes and converts to by default. 我也不记得IronPython ctypes假定并默认转换为什么类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM