Posted By: G Spears Unable to connect from DLL - 09/08/18 02:32 PM
Hello, Environment is Windows 10-64 bit, Delphi Tokyo Patch 3, DOA 4.1.1.0 (at least according to readme.txt file). Scenario. I am using a COM library (AddIn-Express) to build a plug-in for Excel (i.e. a DLL). Everything is working fine and running. I am now wanting to add Oracle connectivity. I have a menu option, which opens a new form. I add an OracleSession component ONLY to this form. This form has a button which does the Oracle processing. For now, there is basically only the following code...

with OracleSession1 do
try
LogonUsername := 'FY19';
LogonPassword := 'FY19';
LogonDatabase := 'orcl';
LogOn;
ShowMessage('Logged on successfully.');
except
on E: EOracleError do
ShowMessage(E.Message);
end;

When I step through the code, the LogOn line is causing an AV with the following... EXCEL.EXE has caused an exception at address... When I click the button, I get the real message... Access Violation in module OraClient12.Dll.

Excel is 64 bit, and my compile option is set to 64 bit. My plugin is working fine with the exception of the newly added OracleSession component. My Delphi Library path is pointing to the 64bit DOA directory. Oracle RDBMS (12.2.0.1.0 64 bit) is located on the same computer. SQLPlus runs fine with the connection string... FY19/FY19@orcl

Any idea what is causing the issue?
Posted By: G Spears Re: Unable to connect from DLL - 09/08/18 02:45 PM
FYI - I did just upgrade to the latest release of DOA - 4.1.3.5 - and have the same problem.
Posted By: Marco Kalter Re: Unable to connect from DLL - 09/10/18 09:26 AM
Do the host application and DLL both access Oracle?
Posted By: G Spears Re: Unable to connect from DLL - 09/10/18 11:16 AM
The host application is Excel. It does NOT access Oracle. Only the Excel plug-In I am writing does. The Plug-In is in the form of a DLL.
Posted By: Marco Kalter Re: Unable to connect from DLL - 09/10/18 11:25 AM
That's odd. What happens if you create a little test project that makes the same connection as a .exe instead of a .dll?
Posted By: G Spears Re: Unable to connect from DLL - 09/10/18 11:34 AM
Just made a small, 64-bit app with just the OracleSession component. I added a button which executed the LogOn code shown in the first post. It connected fine. I tested both from within the Delphi IDE, and running the exe standalone when Delphi is NOT running. Both connected fine.

I also checked that when I load my DLL project into Delphi, I can go to the OracleSession component and check the 'Connected' property, and it connects fine there. (Although I do normally develop with this NOT checked.)

As a final test, I completed exited Delphi. I ran Excel with my DLL. When I try to connect to Oracle, I get the AV.
Posted By: G Spears Re: Unable to connect from DLL - 09/10/18 11:50 AM
Marco, I just sent you (via email) a full stack dump. Hopefully that will shed some light on the root cause.
Posted By: G Spears Re: Unable to connect from DLL - 09/11/18 03:40 PM
Any update on this?
Posted By: Marco Kalter Re: Unable to connect from DLL - 09/12/18 08:28 AM
I sent you the following question by e-mail reply yesterday:

Could it be that the TOracleSession instance is nil when connecting from the DLL?
Posted By: mobermaier Re: Unable to connect from DLL - 12/12/18 09:51 PM
We're having a similar issue connecting from an Apache module loaded into Apache 2.4 (OHS 12.2.1.3) running on Windows 2012.
On the first connect attempt I'm getting:

Access violation at address 00007FFC88515014 in module 'oraclient12.dll'. Write of address 0000000000000018
Posted By: Marco Kalter Re: Unable to connect from DLL - 12/13/18 10:40 AM
Can you create a little test executable that connects to the database, and run it from the same Windows account on the same platform? Just to check that the Oracle Client is able to connect from a standard application?
Posted By: mobermaier Re: Unable to connect from DLL - 12/13/18 12:21 PM
Tried that, that works fine. Apache mod / DLL and test program 64Bit, Delphi XE6 DOA 4.1.3.5, Apache/OHS is running as local system account, the exe with my local administrator account.
"Forcing" a different OCI dll works with the test executable as well. Does not work with OHS, guess the OCI layer is loaded before the Apache module is initialized. Both homes contain the same version of Oracle.

Posted By: mobermaier Re: Unable to connect from DLL - 12/18/18 03:01 PM
I'm still having this problem. Any idea how to identify the actual issue?

I have this very simple apache module, Delphi XE6, DOA 4.1.3.5, OHS 12.2.1.3:

Create a webbroker apache module:

library mod_webbroker;

uses
Winapi.ActiveX,
System.Win.ComObj,
Web.WebBroker,
Web.ApacheApp,
Web.HTTPD24Impl,
WebModuleUnit2 in 'WebModuleUnit2.pas' {WebModule3: TWebModule};

{$E .so}
{$R *.res}

// httpd.conf entries:
(*
LoadModule webbroker_module modules/mod_webbroker.dll
<Location /xyz>
SetHandler mod_webbroker-handler
</Location>
*)
module.
var
GModuleData: TApacheModuleData;
exports
GModuleData name 'webbroker_module';
begin
CoInitFlags := COINIT_MULTITHREADED;
Web.ApacheApp.InitApplication(@GModuleData);
Application.Initialize;
Application.WebModuleClass := WebModuleClass;
Application.Run;
end.


The WebModuleUnit2 only contains TOracleSession and this code:

procedure TWebModule3.WebModule3DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var sResponse, sUserName, sPassword, sDatabase: string;
begin
sResponse := '<html>' +
'<head><title>TEST D.O.A. Connectivity - TOracleSession</title></head>' +
'<body>';

sUserName := 'scott';
sPassword := 'tiger';
sDatabase := 'mydb';

with OracleSession1 do begin
Connected := False;
LogonUsername := sUserName;
LogonPassword := sPassword;
LogonDatabase := sDatabase;
ConnectAs := caNormal;
try
Connected := True;
sResponse := sResponse + Format('<font color="GREEN">%s@%s CONNECTED</font><br>', [sUserName, sDatabase]);
except
on e:Exception do
sResponse := sResponse + Format('<font color="RED">Connect Error [%s@%s]: %s</font><br>', [sUserName, sDatabase, e.Message]);
end;
end;

sResponse := sResponse + '</body></html>';
Response.Content := sResponse;
end;


and the only thing I'm getting is:

Connect Error [scott@mydb]: Access violation at address 00007FFB78895014 in module 'oraclient12.dll'. Write of address 0000000000000018

TNSPing and sqlplus works, and a stand alone application does as well.

Any ideas?
Posted By: Marco Kalter Re: Unable to connect from DLL - 12/19/18 10:26 AM
If the Oracle Home is the same, and a standalone application works correctly, then I can only imagine that there is an environment difference between the standalone application and the Apache DLL. Perhaps there is an account privilege difference, or an environment variable difference (ORACLE_HOME, NLS_LANG, TNS_ADMIN, PATH, ...).
Posted By: Andras Boros Re: Unable to connect from DLL - 01/13/23 02:52 PM
Hello! We are now running into the same problem. Did you finally find a solution?
© Allround Automations forums