03-01-2010 07:43 PM
Hi,
I am looking at modifying DBLog.dll to add a RemoveConnectioin function, which upon calling, it will close the database connection and set "m_pDatalink" to zero. However, I am having problem in compiling the code that it is complaining the following error message:
1>c:\program files\microsoft visual studio 8\vc\atlmfc\include\atlcom.h(1792) : error C2259: 'ATL::CComObject<Base>' : cannot instantiate abstract class
1> with
1> [
1> Base=CTSDBLog
1> ]
1> due to following members:
1> 'HRESULT ITSDBLog::CloseConnection(IDispatch *,unsigned char *)' : is abstract
1> c:\program files\national instruments\teststand 4.2\components\models\teststandmodels\database\dblog\dblog.h(137) : see declaration of 'ITSDBLog::CloseConnection'
1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\atlcom.h(1781) : while compiling class template member function 'HRESULT ATL::CComCreator<T1>::CreateInstance(void *,const IID &,LPVOID *)'
1> with
1> [
1> T1=ATL::CComObject<CTSDBLog>
1> ]
1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\atlcom.h(1872) : see reference to class template instantiation 'ATL::CComCreator<T1>' being compiled
1> with
1> [
1> T1=ATL::CComObject<CTSDBLog>
1> ]
In the code, I have the following declarations and definitions:
1. TSDBLog.h
class CTSDBLog {
...
STDMETHOD(CloseConnection)(/*[in]*/IDispatch *seqContextDisp, /*[in]*/_bstr_t sessionName);
..
}
2. TSDBLog.h
class CTSDatalink {
...
STDMETHOD(CloseConnection)(IDispatch *seqContextDisp, _bstr_t sessionName);
...
}
3. DBLog.idl
interface ITSDBLog : IDispatch {
...
[id(5), helpstring("method CloseConnection")] HRESULT CloseConnection(IDispatch *seqContextDisp, char* sessionName);
...
}
4. TSDatalink.cpp
STDMETHODIMP CTSDatalink::CloseConnection(IDispatch *seqContextDisp, _bstr_t sessionName) {
...
}
5. TSDBLog.cpp
STDMETHODIMP CTSDBLog::CloseConnection(IDispatch *seqContextDisp, _bstr_t sessionName) {
...
}
6. dblog.h
MIDL_INTERFACE(...) ITSDBLog : public IDispatch {
...
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CloseConnection(
IDispatch *seqContextDisp,
unsigned char *sessionName) = 0;
...
}
7. dblog.h
...
/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ITSDBLog_CloseConnection_Proxy(
ITSDBLog * This,
IDispatch *seqContextDisp,
unsigned char *sessionName);
void __RPC_STUB ITSDBLog_CloseConnection_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
...
Did I miss anything?!
Peggy
03-02-2010 11:00 AM
Hi PeggyC,
This article on MSDN may be helpful for you to take a look at. It gives snippets of code that exhibit the error as well as suggestions on how to fix it.
03-02-2010 06:43 PM
Thanks...
I found there was a mismatch in the parameter....
Peggy
03-02-2010 07:06 PM
Hi,
I think I wrote the earlier message too quick. After I have the code compiled, now in TestStand, I inserted an Action Step, but the calling of this new function has the following error:
[Error - An error occurred calling 'CloseConnection' in 'ITSDBLog' of 'zNI TestStand Database Logging'
What's wrong?!
Peggy
03-03-2010 05:35 PM
Hi Peggy,
I think that it would be helpful for you to be able to step into the DLL to get more information on where the error is occurring. Within Visual Studio, we can go to Debug --> Attach to Process to attach to the sequence editor. We can run your sequence and use normal troubleshooting procedures (e.g. breakpoints, stepping through your code) to better determine where this error is coming from and why.
03-03-2010 05:58 PM
I attached the Visual Studio with "SeqEdit.exe" process. From TestStand, I placed a breakpoint on the step that calls DBLog.dll RemoveConnection function. When Test Stand execution halts, I select "Step Into (F8)".
I am not able to step into the Visual Studio development environment. Did I missing any step?!
I am using Visual C++ 2005, and TestStand 4.2.
Peggy
03-03-2010 06:16 PM - edited 03-03-2010 06:18 PM
Hi Peggy,
Also, here are additional instructions on another method that you could try that I found on a Knowledgebase on our website. This will work for you if you have Measurement Studio installed. If not, there is another article linked to it that will be helpful and gives step by step instructions.
03-03-2010 07:07 PM
Thanks, Kelly. The instruction you point to is exactly of what I did, except I am not able step into the .NET assembly code.
However, I did some troubleshoot by incrementally build the function with messageBox to check the variables. I come down to the the following code:
STDMETHODIMP CTSDBLog::CloseConnection(IDispatch *seqContextDisp, IDispatch *optionsDisp)
{
HRESULT result = S_OK;
TS::SequenceContextPtr pContext(seqContextDisp);
PRE_API_FUNC_CODE
AFX_MANAGE_STATE(AfxGetStaticModuleState())
if( m_pDatalink ) {
SM::IInstrSessionMgrPtr pSMgr;
SM::IInstrSessionPtr pSession;
// Get Database Schema Name to create the unique Datalink property name
TS::PropertyObjectPtr pOptions(optionsDisp);
_bstr_t propName(EXECUTION_DATALINK_PROPERTY);
_bstr_t schemaName = pOptions->GetValString("DatabaseSchema.Name", 0);
if (!(!schemaName))
propName += schemaName;
// FindAndReplace '.' with '_' and any other odd characters
MakeValidName(propName);
m_pDatalink = 0;
// Open session manager
result = pSMgr.CreateInstance(__uuidof(SM::InstrSessionMgr));
if (result)
RAISE_ERROR_WITH_DESC(TSDBLogErr_SessionManagerError, result, "");
pSession = pSMgr->GetInstrSession(propName, false);
if( pSession )
pSession->DetachData(DATALINK_ATTACH_NAME);
else
MessageBox(NULL,"unable to get session","DBLog",0);
m_dLastChangeCount++;
}
POST_API_FUNC_CODE(IID_ITSDBLog, pContext->Engine)
}
This code builds, and closes the database file. However, because this is my first attemp trying to modify the TestStand DLL, I wonder, if is possible, that you can help to review the code and see if I missed anything.
Thanks.
Peggy
03-10-2010 03:55 PM
Hi Peggy,
Just to clarify, you were able to successfully build the code, close the database connection, and achieve your original task, correct?
03-10-2010 04:20 PM
I think so, as I can see Access' temporary file closed.
Peggy