LabVIEW + C-DLL:EIP = 0x00000000 处的访问冲突 (0xC0000005)
LabVIEW + C-DLL: Access violation (0xC0000005) at EIP = 0x00000000
信息:
实验室视图:2019
版本:19.0.1(32 位)
操作系统: Windows 64 位
Labview 在无限期后完全崩溃。我调用了三个函数C-DLL。我一遍又一遍地遍历 DLL 的所有函数。大约 2 分钟到一个小时后,Labview 无故崩溃。
OpenConnection()
的调用:
QueryOpenConnectionStatus()
的调用:
CloseConnection()
的调用:
TConnectionResult
的类型定义
按照给定的Headerfile.h
#ifndef __epMCOMLib_h_
#define __epMCOMLib_h_
#include <stdint.h>
#include <stddef.h>
#define DLLIMPORT __declspec(dllimport)
#pragma pack (push,1)
typedef struct {
uint16_t DLLFailureCode;
uint8_t ConnectionStatus;
uint32_t SystemFailureCode;
} TConnectionResult;
#pragma pack (pop)
#ifdef __cplusplus
extern "C" {
#endif
DLLIMPORT uint16_t __cdecl OpenConnection(uint8_t PortType,
char * PortName,
uint32_t OnConnectSucces,
uint32_t * Handle);
DLLIMPORT void __cdecl QueryOpenConnectionStatus(uint32_t Handle,
TConnectionResult * Result);
DLLIMPORT uint16_t __cdecl CloseConnection(uint32_t Handle);
#ifdef __cplusplus
} // extern "C"
#endif
#endif //#ifndef __epMCOMLib_h_
DLL 完美运行。为此,我将 DLL 集成到 Python、LabWindows/CVI、C++ 和 Delphi 中。 这些编程语言没有崩溃!
任何人都可以给我任何关于如何进一步隔离或消除错误的有用提示。
即使执行了DLL的一个函数然后关闭了DLL,它仍然会导致崩溃。仿佛还在记忆中。大海捞针的感觉
根据我的经验,有时使用LabVIEW调用DLL会导致此类问题,并且没有具体原因和解决方案(即使是NI技术支持)。
尝试以管理员权限启动您的 LabVIEW 应用程序。在某些情况下,这可以解决问题。
运行线程在UI线程而不是任何线程!
在 DLL 的日志文件中,我可以看到线程已附加和分离。我怀疑这会导致内存违规。由于 Labview 被其调用的 DLL 击落。
信息: 实验室视图:2019 版本:19.0.1(32 位) 操作系统: Windows 64 位
Labview 在无限期后完全崩溃。我调用了三个函数C-DLL。我一遍又一遍地遍历 DLL 的所有函数。大约 2 分钟到一个小时后,Labview 无故崩溃。
OpenConnection()
的调用:
QueryOpenConnectionStatus()
的调用:
CloseConnection()
的调用:
TConnectionResult
按照给定的Headerfile.h
#ifndef __epMCOMLib_h_
#define __epMCOMLib_h_
#include <stdint.h>
#include <stddef.h>
#define DLLIMPORT __declspec(dllimport)
#pragma pack (push,1)
typedef struct {
uint16_t DLLFailureCode;
uint8_t ConnectionStatus;
uint32_t SystemFailureCode;
} TConnectionResult;
#pragma pack (pop)
#ifdef __cplusplus
extern "C" {
#endif
DLLIMPORT uint16_t __cdecl OpenConnection(uint8_t PortType,
char * PortName,
uint32_t OnConnectSucces,
uint32_t * Handle);
DLLIMPORT void __cdecl QueryOpenConnectionStatus(uint32_t Handle,
TConnectionResult * Result);
DLLIMPORT uint16_t __cdecl CloseConnection(uint32_t Handle);
#ifdef __cplusplus
} // extern "C"
#endif
#endif //#ifndef __epMCOMLib_h_
DLL 完美运行。为此,我将 DLL 集成到 Python、LabWindows/CVI、C++ 和 Delphi 中。 这些编程语言没有崩溃!
任何人都可以给我任何关于如何进一步隔离或消除错误的有用提示。 即使执行了DLL的一个函数然后关闭了DLL,它仍然会导致崩溃。仿佛还在记忆中。大海捞针的感觉
根据我的经验,有时使用LabVIEW调用DLL会导致此类问题,并且没有具体原因和解决方案(即使是NI技术支持)。 尝试以管理员权限启动您的 LabVIEW 应用程序。在某些情况下,这可以解决问题。
运行线程在UI线程而不是任何线程!
在 DLL 的日志文件中,我可以看到线程已附加和分离。我怀疑这会导致内存违规。由于 Labview 被其调用的 DLL 击落。