Reputation: 1
I am writing a program for school and I have the curious problem of it not running outside of Visual Studio. Whether release or debug, whether run with debugging or not, it will run when run from Visual Studio. However, when I run it from Explorer, it will open and spawn the windows I require, but fail when I run the "actual program part".
For context, the program takes data from a number of devices (radiation detectors) and does some basic processing as well as saving the raw data to a text file. I am using a DLL and some ActiveX controls provided by the hardware vendor, and the program is based upon their sample code. When the program runs, a simple box with a "Spawn" button appears. Hitting this will open up identical windows, which can each be used to connect to a different detector. After making some settings changes, one can hit "start" on each of these to begin a thread that polls the device for data from time to time, etc. The program crashes when the "start" button is activated.
I am using C++ with MFC.
The only error I can extract from the whole thing is: 0xC0150010: The activation context being deactivated is not active for the current thread of execution.
Are there any ideas? Is there any other information I can provide that will be useful?
EDIT1:
int nResponse = dlg.DoModal();
This is the only bit of code in the stack trace once it breaks that is anything in my code.
I ran Dependency Walker and added a few DLL files to the directory:
mcbcio32.dll
mcbloc32.dll
ieshims.dll
EDIT2: No more errors with depends.exe.
Here is the "start" code:
void CCraneWowDlg::OnStart() { CStatic *pLatest = (CStatic *)GetDlgItem(IDC_LATEST); CEdit *pFilePath = (CEdit *)GetDlgItem(IDC_FILEPATH); CString strFilePath, strText; CFile dataFile; LISHDR myHeader; LPTSTR errText = "lol"; try { pFilePath->GetWindowText(strFilePath); if (!dataFile.Open(strFilePath, CFile::modeCreate | CFile::modeReadWrite, NULL)){ AfxThrowOleDispatchException(0xab,(LPCTSTR)"file open not work",0); } else { //lock the dropbox, set up the device. //TODO: lock dropbox pLatest->SetWindowText((LPCSTR)m_ConnCtl.Comm((LPCSTR)"STOP")); pLatest->SetWindowText((LPCSTR)m_ConnCtl.Comm((LPCSTR)"CLEAR_ALL")); pLatest->SetWindowText((LPCSTR)m_ConnCtl.Comm((LPCSTR)"START")); UpdateInfo(); //write the real header MakeHeader(&myHeader); dataFile.Write(&myHeader,256); dataFile.Close(); //end real header //begin getting data // AfxBeginThread((AFX_THREADPROC)GetData,(LPVOID)&dataFile,THREAD_PRIORITY_NORMAL,0,0,NULL); //TODO use thread ID to close it if stop is pressed // GetData(&dataFile); //make this a thread with a loop //use CThread CEdit *pSize = (CEdit *)GetDlgItem(IDC_SIZE); CEdit *pEvery = (CEdit *)GetDlgItem(IDC_EVERY); CEdit *pMax = (CEdit *)GetDlgItem(IDC_MAX); pSize->GetWindowText(strText); m_Size = _tstof(strText); pEvery->GetWindowText(strText); m_Every = _tstof(strText); pMax->GetWindowText(strText); m_Max = _tstof(strText); m_FilePath = strFilePath; m_Address = m_DListCtl.GetSelAddress(); OutputDebugString("here we are about to start the thread\n"); m_DataThread.m_pDlg = this; m_DataThread.Start(); //TODO: thread // GetData(); // dataFile.Close(); } } catch(COleDispatchException *pE) { pE->GetErrorMessage(errText, 30, NULL); pE->Delete(); pLatest->SetWindowText(errText); } UpdateInfo(); // m_ConnCtl.Comm((LPCSTR)"STOP"); }
Thanks
Upvotes: 0
Views: 1917
Reputation: 283614
Most likely, the current working directory is different, so the DLL search path is different. Maybe a different version of the device library is being loaded.
The Dependency Walker tool is often helpful in troubleshooting these problems.
Upvotes: 1