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;
}