I have the following code:
IDatabasePtr tempDB;
pDBService->Open(dbPath2, modeDefault, &tempDB);
This works fine.
If I do the following, using the same path:
if( (iRet=pUIService->OpenDatabase(dbPath2, &pIUIDB)) != kServiceNoErr )
iRet is kServiceErrInvalidParam.
Also, if I do either of the following:
if( (iRet=pUIService->OpenDatabase(dbPath2, NULL)) != kServiceNoErr )
or
if( (iRet=pUIService->OpenDatabase(dbPath2)) != kServiceNoErr )
EndNote throws an AccessViolation exception inside the call to OpenDatabase and does not return a ServiceError.
I will need to look into this more, but it appears that IUIService::OpenDatabase only takes a single argument, the path:
//OpenDatabase
if( (iRet=pIUIService->OpenDatabase(gszOpenDBTestPath)) != kServiceNoErr )
gwOut << "FAILURE: IUIService::OpenDatabase " << iRet << "\n";
else
gwOut << "SUCCESS: IUIService::OpenDatabase\n";
But looking at the IUIService.h header, I see it shows two arguments…
Hmm looking at the header again, I see that the second argument is optional, and you tried opening it that way in your last example. Does the database you are trying to open already exist?
Yes, it exists.
I can successfully open it using IDatabaseService->Open.
Is this code being run in the main EndNote thread, or is it being run in another thread triggered by IPC?
It should be in the main EndNote thread… Let me see if I can find a way to be 100% sure.
Yeah, it was being invoked in a child thread… I found out a way to force it to be invoked in EndNote’s thread and it works now!