google搜索 站内搜索                 软件测试门户 | 软件测试培训 | 文章资料精选 | 软件测试论坛 | 测试解决方案 | 软件测试博客 | 测试招聘求职 
打印

[求助] DLL调用问题

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:写成绝对路径和复制到脚本目录下都没有效果。
请问有那位高手能帮帮忙?谢谢了。

TOP

有那位能帮帮忙啊!!!!!!!!

TOP

很想帮你,但我没遇到过此类情况!

TOP

是不是你的DLL有问题.
████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

TOP

我在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: C interpreter run time error: Action.c (8):  Error -- memory violation : Exception ACCESS_VIOLATION received.
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()
.

[ 本帖最后由 wyy83 于 2007-12-4 15:15 编辑 ]
读书在于明理,做人在于诚信,生活在于体验与感悟......

TOP

DLL没有问题,在.net中测试过的。

TOP

Action.c(8): Error: C interpreter run time error: Action.c (8):  Error -- memory violation : Exception ACCESS_VIOLATION received.
是内存方面的问题和我的不一样。

TOP

我也出现了这个问题  很想知道解决办法

TOP

比如用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

TOP

lr_load_dll 不能装载.net的DLL的,只能装载标准c导出函数的DLL
关于出现 Error -- memory violation : Exception ACCESS_VIOLATION received.
是因为内存违规范围,通常是数组越界了。

TOP

.net的dll和我们常用的动态链接库不一样, 它的dll还是需要.net的运行环境(我碰到过这个问题的,呵呵)
用C++写动态链接库吧

TOP

.net生成的是托管dll

并非原生代码生成的。

TOP

偶对.net没有研究

一般都是
1)写普通函数,main函数测试
2)封装 DLL
3)用 LoadLibrary API 动态加载,再获取函数地址执行测试
4)lr_load_dll 调用测试

TOP

 
当前时区 GMT+8, 现在时间是 2008-12-6 00:10Copyright(C)上海博为峰软件技术有限公司 2001-2007 电话:021-64471599-8017
当您在访问网站、论坛及博客过程中遇到问题时可发送email:webmaster@51testing.com或发送论坛短信至管理员风在吹