sherry1980 2007-12-4 10:40
DLL调用问题
我在.NET中用C#完成了一个DLL,在LoadRunner中调用。
Action()
{
lr_load_dll("TestAgain.dll");
lr_output_message ("%s",add(3));
return 0;
}
编译没有问题,但是一运行便报
Action.c(5): 错误: C interpreter run time error: Action.c (5): Error -- Unresolved symbol : add.
Action.c(5): 通知: CCI 跟踪: Compiled_code(0): Action()
错误
ps:写成绝对路径和复制到脚本目录下都没有效果。
请问有那位高手能帮帮忙?谢谢了。
sherry1980 2007-12-4 12:20
有那位能帮帮忙啊!!!!!!!!
wyy83 2007-12-4 15:14
[b][/b]我在VC++6.0下编译了个DLL
在LR中调用,运行结果是对的,但是也有错误提示.
#include "lrs.h"
Action()
{
lr_load_dll("test.dll");
lr_output_message("%s",add(2,3));
return 0;
}
*************结果******************
Action.c(8): Error: [color=Red]C interpreter run time error: Action.c (8): Error -- memory violation : Exception ACCESS_VIOLATION received.[/color]
Action.c(8): Notify: CCI trace: Action.c(8): lr_output_message(0x00af0149 "%s", 5)
.
Action.c(8): Notify: CCI trace: Compiled_code(0): Action()
.
[[i] 本帖最后由 wyy83 于 2007-12-4 15:15 编辑 [/i]]
sherry1980 2007-12-4 16:29
DLL没有问题,在.net中测试过的。
sherry1980 2007-12-4 16:31
Action.c(8): Error: C interpreter run time error: Action.c (8): Error -- memory violation : Exception ACCESS_VIOLATION received.
是内存方面的问题和我的不一样。
liangjz 2008-5-11 01:24
比如用vc6 编写dll是可以的 .
选取DLL 工程
头文件如下
__declspec(dllexport) int __stdcall base64_decode (const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen) ;
__declspec(dllexport) int __stdcall base64_encode(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen) ;
再插入一个.def文件
LIBRARY BTREE
EXPORTS
base64_decode
base64_encode
实现base64
编译成base64Lib.dll。
然后再在 LR 中调用。
unsigned char input[]="[email=id=12333&u=liangjz&examid=1111&mail=yang@yahoo]id=12333&u=liangjz&examid=1111&mail=yang@yahoo[/email]";
unsigned char output[129]={0};
int rv;
unsigned long len=128;
lr_load_dll("D:\\c_proj\\base64Lib\\Debug\\base64Lib.dll");
rv= base64_encode(input,strlen(input),output,&len);
lr_error_message("rv=%d,out=%s\r\n",rv,output);
编译成DLL
DeViLIvy 2008-5-12 09:57
lr_load_dll 不能装载.net的DLL的,只能装载标准c导出函数的DLL
关于出现 Error -- memory violation : Exception ACCESS_VIOLATION received.
是因为内存违规范围,通常是数组越界了。
davidwang_2004 2008-5-12 12:02
.net的dll和我们常用的动态链接库不一样, 它的dll还是需要.net的运行环境(我碰到过这个问题的,呵呵)
用C++写动态链接库吧
liangjz 2008-5-12 23:40
偶对.net没有研究:)
一般都是
1)写普通函数,main函数测试
2)封装 DLL
3)用 LoadLibrary API 动态加载,再获取函数地址执行测试
4)lr_load_dll 调用测试