passing session to dll variable

igon

Member²
What is the update on the fix for the following that was sent to me?

I have continued my investigation, and have found that the following causes
the problem:

1. In the host application a variable is declared.
2. In the DLL this variable is deleted.
3. In the DLL a new variable is declared => EListError.

It turns out that this problem occurs in the TCollection implementation,
inside Classes.pas. Variables are collection items, and you can reproduce
the problem by creating a TCollection instance in the host application,
creating an item on it, freeing the item in the DLL, and adding a new one.
The EListError will occur in this situation as well.

I have no idea what is going on here, and I can't find any reference to it
in any of the Delphi resources.

For the time being you can perhaps use the ExternalLDA property to share
sessions between a host application and DLL's. This should work just fine
(no memory management issues), and has an extra advantages that you don't
need ShareMem / borlndmm.dll, and that the DLL can be compiled with a
different version of Direct Oracle Access than the host application.

The downside of the ExternalLDA property is that you must set
TOracleSession.Preferences.UseOCI7 to True. As a result, you cannot use any
Net8 specific objects (CLOB's, BLOB's, Objects). We hope to address this in
the next patch release.

Greetings,
Marco Kalter (support@allroundautomations.nl)
Allround Automations (http://www.allroundautomations.nl)
 
Version 3.3.3 fixes this issue. You can now use TOracleSession.Share(ToSession) to share a physical database session between 2 TOracleSession instances. This will work regardless of the OCI version (SQL*Net or Net8), and doesn't require the ShareMem unit if you are sharing a session between a host application and a DLL.

------------------
Marco Kalter
Allround Automations
 
I tried using the share method on the load of my dll with the following code:

function UT_Load(AppHandle:THandle;ASession:TOracleSession):Boolean;StdCall;
var
Antek_Ini: TIniFile; // INI file handle
begin
Result := TRUE;
try
Application.Handle := AppHandle;
FM_MacroSetup := TFM_MacroSetup.Create
Application);
FM_Notes := TFM_Notes.Create(Application);
FM_ShowMacros := TFM_ShowMacros.Create(Application);
DM_Util := TDM_Util.Create(Application);
DM_Util.SES_Common.Share(ASession);

// read INI file to get workstation number
Antek_Ini := TIniFile.Create('c:\Antek\Antek.ini');
try
{Logon to the database}
if not DM_Util.SES_Common.Connected then
begin
Result := FALSE;
Exit;
end;
finally
Antek_ini.Free;
end;

UT_SetApplicationVersion(ExtractFileName(GetVersionInf(TRUE)),GetVersionInf(FALSE));

except
on E:Exception do
begin
ShowMessage(E.Message);
Result := FALSE;
Exit;
end;
end;
end;

On the share method I get the following error.

ExternalLDA only valid when connected through OCI7 and it will not share the session. Please help. Can you provide me with an example or sample project that does not use OCI7=TRUE?

Thanks.
 
The problem was that I was calling the share in the dll without first logging in the query in the main application. Could you please clearify the error for others in the future who may do this or put it in the help file. Thanks alot for the demo -- it helped solve the problem.
 
I would have expected a better error message, so that you immediately know what's wrong. That is how we are going to address this problem of course.

------------------
Marco Kalter
Allround Automations
 
Back
Top