Print Thread
Page 1 of 2 1 2
Unable to connect from DLL
#58299 09/08/18 02:32 PM
Joined: Jun 2011
Posts: 12
G
Member
OP Offline
Member
G
Joined: Jun 2011
Posts: 12
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?

Last edited by G Spears; 09/08/18 02:53 PM.
Re: Unable to connect from DLL
G Spears #58300 09/08/18 02:45 PM
Joined: Jun 2011
Posts: 12
G
Member
OP Offline
Member
G
Joined: Jun 2011
Posts: 12
FYI - I did just upgrade to the latest release of DOA - 4.1.3.5 - and have the same problem.

Last edited by G Spears; 09/08/18 02:53 PM.
Re: Unable to connect from DLL
G Spears #58302 09/10/18 09:26 AM
Joined: Aug 1999
Posts: 22,175
Member
Offline
Member
Joined: Aug 1999
Posts: 22,175
Do the host application and DLL both access Oracle?


Marco Kalter
Allround Automations
Re: Unable to connect from DLL
Marco Kalter #58304 09/10/18 11:16 AM
Joined: Jun 2011
Posts: 12
G
Member
OP Offline
Member
G
Joined: Jun 2011
Posts: 12
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.

Re: Unable to connect from DLL
G Spears #58305 09/10/18 11:25 AM
Joined: Aug 1999
Posts: 22,175
Member
Offline
Member
Joined: Aug 1999
Posts: 22,175
That's odd. What happens if you create a little test project that makes the same connection as a .exe instead of a .dll?


Marco Kalter
Allround Automations
Re: Unable to connect from DLL
Marco Kalter #58306 09/10/18 11:34 AM
Joined: Jun 2011
Posts: 12
G
Member
OP Offline
Member
G
Joined: Jun 2011
Posts: 12
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.

Last edited by G Spears; 09/10/18 11:41 AM.
Re: Unable to connect from DLL
G Spears #58307 09/10/18 11:50 AM
Joined: Jun 2011
Posts: 12
G
Member
OP Offline
Member
G
Joined: Jun 2011
Posts: 12
Marco, I just sent you (via email) a full stack dump. Hopefully that will shed some light on the root cause.

Re: Unable to connect from DLL
G Spears #58311 09/11/18 03:40 PM
Joined: Jun 2011
Posts: 12
G
Member
OP Offline
Member
G
Joined: Jun 2011
Posts: 12
Any update on this?

Re: Unable to connect from DLL
G Spears #58315 09/12/18 08:28 AM
Joined: Aug 1999
Posts: 22,175
Member
Offline
Member
Joined: Aug 1999
Posts: 22,175
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?


Marco Kalter
Allround Automations
Re: Unable to connect from DLL
Marco Kalter #59191 12/12/18 09:51 PM
Joined: Apr 2006
Posts: 10
M
Member
Offline
Member
M
Joined: Apr 2006
Posts: 10
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

Re: Unable to connect from DLL
mobermaier #59195 12/13/18 10:40 AM
Joined: Aug 1999
Posts: 22,175
Member
Offline
Member
Joined: Aug 1999
Posts: 22,175
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?


Marco Kalter
Allround Automations
Re: Unable to connect from DLL
Marco Kalter #59197 12/13/18 12:21 PM
Joined: Apr 2006
Posts: 10
M
Member
Offline
Member
M
Joined: Apr 2006
Posts: 10
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.


Re: Unable to connect from DLL
mobermaier #59240 12/18/18 03:01 PM
Joined: Apr 2006
Posts: 10
M
Member
Offline
Member
M
Joined: Apr 2006
Posts: 10
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?

Re: Unable to connect from DLL
mobermaier #59246 12/19/18 10:26 AM
Joined: Aug 1999
Posts: 22,175
Member
Offline
Member
Joined: Aug 1999
Posts: 22,175
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, ...).


Marco Kalter
Allround Automations
Re: Unable to connect from DLL
G Spears #64382 01/13/23 02:52 PM
Joined: Jan 2023
Posts: 6
A
Member
Offline
Member
A
Joined: Jan 2023
Posts: 6
Hello! We are now running into the same problem. Did you finally find a solution?

Page 1 of 2 1 2

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.033s Queries: 15 (0.008s) Memory: 2.5894 MB (Peak: 3.0378 MB) Data Comp: Off Server Time: 2024-03-29 10:44:10 UTC
Valid HTML 5 and Valid CSS