cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to load C++ DLL

SOLVED
krkarthik_info
Frequent Contributor

Unable to load C++ DLL

Hi All,

 

I have been trying to access routines from C++ DLL through TestComplete. But am getting the error as "Unable to load the dll library".

 

Using the below code to load the dll in TestComplete

function CallDLL()
{
var Def_DLL = DLL.DefineDLL("EXAMPLE");  

var Lib = DLL.Load("C:\\EXAMPLE.dll");
}

Could anyone suggest how to get this resolved.

 

Thanks in advance.

 

Thanks,

Karthik K R

1 ACCEPTED SOLUTION

Accepted Solutions
krkarthik_info
Frequent Contributor

Re: Unable to load C++ DLL

Hi Alex,

 

Thanks for the suggestions. Actually I have gone through those limitations. 

 

My DLL were referring two more DLL's. So I tried to call those DLL's first using DLL.Load() before calling my actual DLL. 

This way I was able to resolved the issue on loading the DLL.

 

After this, my next question arise out of the situation is:

Can we call the C++ routines which resides inside the class as

ClassName.RoutineName(arguments)

Thanks in advance.

 

Thanks,

Karthik K R

 

View solution in original post

5 REPLIES 5
AlexKaras
Community Hero

Re: Unable to load C++ DLL

Hi,

 

C++ DLL

Does this DLL follows requirements described here: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calli... ?

Especially these ones:

 

  • Only standalone exported routines can be called from TestComplete tests. There is no way to call methods of exported classes.

  • The DLL routine to be called must match the stdcall calling convention.

 

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
krkarthik_info
Frequent Contributor

Re: Unable to load C++ DLL

Hi Alex,

 

Thanks for the suggestions. Actually I have gone through those limitations. 

 

My DLL were referring two more DLL's. So I tried to call those DLL's first using DLL.Load() before calling my actual DLL. 

This way I was able to resolved the issue on loading the DLL.

 

After this, my next question arise out of the situation is:

Can we call the C++ routines which resides inside the class as

ClassName.RoutineName(arguments)

Thanks in advance.

 

Thanks,

Karthik K R

 

View solution in original post

AlexKaras
Community Hero

Re: Unable to load C++ DLL

Hi,

 

> ClassName.RoutineName(arguments)

I am pretty sure this is not possible because:

a)  In order to do this, the class instance must be created first; and

b) There is no way for TestComplete to get info as for how to call this or that method of some class. COM objects provide such information, but not regular classes.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
krkarthik_info
Frequent Contributor

Re: Unable to load C++ DLL

Hi Alex,

 

Thanks for your reply.

 

I believe we can get the instance of the class through calling constructor like how dotNET object allows us to call the class constructors (zctor, zctor1..). But I am not sure how to achieve this through DLL object.

 

Thanks,

Karthik K R

AlexKaras
Community Hero

Re: Unable to load C++ DLL

Hi,

 

dotNET and C++ runtime have quite different architecture and I am far nor sure that even if you manage to call class constructor, created object can be stored in script runtime memory and be accessible.

You may contact Support via the https://support.smartbear.com/message/?prod=TestComplete form to ask their opinion.

 

As a possible option, you may consider to create a helper DLL (or COM object) that will create an instance of this class and call its methods via regular DLL exported functions.

 

P.S. Out of curiosity - what is your goal? Is it possible to achieve it through, say, functionality provided by .Net via CLR  Bridge in TestComplete?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements