LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

new activex

Hi
I have an ActiveX diver for snmp communication.
I wrote some function with it and it's OK (when I run it from CVI).
when I make a dll and try to run it from TestStand there is an Error in
the function : "NewActivexCtrl" that in the function
"DartSnmp_NewIManager"
return: -143 "Activex control Error"

(I didn't write this file,It's Dart's snmp file, that use this function).

why when I run it as c file it's OK
and as dll something wrong.
what should I do?

Please write your answer to :
alon.shalil@alvarion.com
thanks

Alon
Download All
0 Kudos
Message 1 of 2
(3,025 Views)
Hello,

It sounds like this may be a threading problem. When you run your CVI executable, each thread is CoInitialized as Apartment threaded. However, when you run from TestStand, TestStand coinitializes its threads as Multithreaded. Therefore, you may want to create a wrapper that is called from TestStand, and inside the wrapper, create a new thread that coinitializes the thread as Apartment threaded. Here is some code that will help you pinpoint if this is the problem.
You will need to double check the code so that everything is poiniting to the write files and add your code to the part titled "Add Your Code Here".

CVI Code:

#include
#include "MyServer.h" // Or the name of your server's header file
#include
#include
#include "toolbox.h"
#include
#include
#include

DWORD WINAPI myThreadFunc(LPVOID lpParameter);

static CAObjHandle MyServer=0;�
static char errorString[1024];�

int main (int argc, char *argv[])
{
int�������� error = 0;
LPVOID lpParameter;���� // thread argument
LPDWORD lpThreadId;���� // thread identifier
HANDLE threadHndl;
if (InitCVIRTE (0, argv, 0) == 0)
return -1;��� /* out of memory */

//Call the function in a new thread that will be coinitialized to
// Apartmentthreaded
threadHndl=CreateThread(
� NULL, // SD
� 0,���������� // initial stack size
� myThreadFunc, // thread function
� lpParameter, // thread argument
� 0,������� // creation option
� NULL���� // thread identifier
);
if (threadHndl)
errChk(WaitForSingleObject (threadHndl, INFINITE));

Error:
// free all resources
if (error<0){
MessagePopup ("error occurred", "");
return error;
}

DWORD WINAPI myThreadFunc(LPVOID lpParameter){

int error = 0;
ERRORINFO errorInfo;

errChk( CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));

//*******************************
// Add your code here
//********************************

CoUninitialize( );

Error:
// free all resources
CA_DiscardObjHandle(MyServer);
if (error<0)
CA_GetAutomationErrorString (error, errorString, 1024);
MessagePopup ("error occurred", errorString);
return error;
}
Message 2 of 2
(3,025 Views)