Access violation error on create session in pool

Nau13

Member
Hi!

Enveronment:
Server: 9.2.0.5.0
Client: 9.2.0.5.0
DOA: 4.0.7.1

Application consist of main proggram (exe) and plugins (dll).
Main programm has interface with method for access to main session (TOracleSession) and session pool (TOracleSessionPool).

On initialization, plugin access to main session and pool.
if Supports(HostApplication.MainForm, IOraSess, SessFrm) then
begin
fSess := SessFrm.Session;
fSessPool := SessFrm.SessionPool;
end;

Plugin (dll) has MDIChild form with TOracleSession component.
On initialization this form:
frm1.Sess.Pool := fSessPool;
frm1.Sess.LogOn;

this work

And, this plugin (dll) has other MDIChild form with TOracleSession component.

On initialization this form:
frm2.Sess.Pool := fSessPool;
frm2.Sess.LogOn;

If at first open session in frm1, then close this session and open session in frm2 in this case no exceptions. (in second case uses session from pool, not create new session)

If at first open session in frm2, I have exception: Access violation at 00000000.
This exception occurred in TOracleSessionPool.CreateOCISession
at
OCICall(OCIAttrSet(authinfop, OCI_HTYPE_AUTHINFO,
PChar(ASession.LogonUsername), Length(ASession.LogonUsername),
OCI_ATTR_USERNAME, errhp));

TOracleSessionPool:
Homogeneous: True
StatmentCache: True/False
PoolType: ptOracle
Min: 1 (for main session)
Max: 50

all TOracleSession:
Pooling: spInternal
StatmentCache: True/False

What reason of tish exception?

Thanks!
 
If you want to pass object instances from a host application to a DLL, you probably need to use the ShareMem unit. From the Writing Dynamically Loaded Libraries section of the Delphi Help:
Shared-Memory Manager (Win32 Only)
On Win32, if a DLL exports routines that pass long strings or dynamic arrays as parameters or function results (whether directly or nested in records or objects), then the DLL and its client applications (or DLLs) must all use the ShareMem unit. The same is true if one application or DLL allocates memory with New or GetMem which is deallocated by a call to Dispose or FreeMem in another module. ShareMem should always be the first unit listed in any program or library uses clause where it occurs.

ShareMem is the interface unit for the BORLANDMM.DLL memory manager, which allows modules to share dynamically allocated memory. BORLANDMM.DLL must be deployed with applications and DLLs that use ShareMem. When an application or DLL uses ShareMem, its memory manager is replaced by the memory manager in BORLANDMM.DLL.
 
Thanks.

But, I known about this! And ShareMem unit added in both project (host and plugin). (This is not my first project with using interfaces for interacting between host-app and plugin).

In other projects I used single TOracleSession and share it between host-app and plugins. No problem.

But, in this case, I use own TOracleSession for each plugin and get session from pool.
I have made experiments:
1. copy frm1 (with working code, e.g. TOracleSession successfull get session from pool) to another form in this project. It also works!
2. copy component TOracleSession from frm1 to frm2. It does not work.

(in frm1 and frm2 lists in uses is equal)

Thanks.
 
Can you check if OCIAttrSet is assigned within the DLL:

if not Assigned(OCIAttrSet) then ShowMessage('OCIAttrSet is unassigned');

If it is indeed unassigned, it may necessary to call InitOCI within the DLL. This procedure is located in the OracleCI unit, which you will need to "use" in the DLL.
 
Back
Top