问题描述
TADOConnection
无法在Delphi ISAPI App的应用程序初始化部分进行连接( TISAPIApplication
):
TADOConnection
is failing to connect in the application initialization section of Delphi ISAPI App (TISAPIApplication
):
应用程序使用Delphi XE SPI构建,运行Win 7 64 / IIS 7.5和WinServer 2008 RS2 - 它无法在全局ISAPI应用程序上下文中与ADO连接。 (示例代码使用MS-SQLServer OLEDB - 但我们也无法使用Sybase ASE提供程序。)
Application is built with Delphi XE SPI, running Win 7 64/IIS 7.5 and WinServer 2008 RS2 - it cannot connect with ADO in the global ISAPI application context. (Example code is using MS-SQLServer OLEDB - but we also fail using Sybase ASE provider.)
以下代码在 conn.Open 被调用 -
TADOConnection.open
永远不会返回 - ISAPI应用程序在la-la land中挂起,没有异常引发:
The following code fails when conn.Open
is called - TADOConnection.open
never returns - ISAPI app hangs in la-la land, no exception raised:
library ISAPIBareBones;
uses
ActiveX,
ADODB,
(...)
var
conn: TADOConnection;
begin
CoInitFlags := COINIT_MULTITHREADED;
Application.Initialize;
coinitialize(nil);
conn := TADOConnection.Create(Application);
conn.ConnectionString := 'Provider=SQLOLEDB.1;xxx';
//Fails here:
try
conn.Open;
except on e:exception do
logException(e)
end;
Application.WebModuleClass := WebModuleClass;
Application.Run;
end.
特定请求处理程序(Delphi webAction)中的相同代码运行正常。
The same code within a specific request handler (Delphi webAction) runs fine.
我们怀疑ISAPI应用程序级别的IIS中的执行权限存在问题。但据我们所知,从webServer本身到特定虚拟目录的整个IIS应用程序堆栈和ISAPI dll本身都在具有相同执行权限的相同凭据下运行。
We suspect a problem with execution privileges in IIS at the ISAPI application level. But as far as we can tell, the entire IIS application stack from the webServer itself down to the specific virtual directory and the ISAPI dll itself are all running under the same credentials with same execution privileges.
同时,我的解决方法是从http响应调用(ISAPI线程)中初始化数据库基础结构,然后检查它是否在每次后续调用时初始化。这有效,但让我感到困扰的是一些我不想处理的限制。
Meanwhile, my workaround has been to initialize the database infrastructure from within an http response call (an ISAPI thread), and then simply check that it's initialized on each subsequent call. This works, but encumbers me with some constraints that I'd prefer not to deal with.
如何在<$ c $中建立ADO数据库连接c> TISAPIApplication 实例,在处理传入请求之前。
How can I make ADO database connections in a TISAPIApplication
instance, before handling incoming requests.
推荐答案
我认为问题你运行的代码是在dll的主程序中运行的。这部分初始化是非常严格的,例如您可能无法加载任何dll,也不允许您拨打
来调用CoInitialize(请参阅)。
您的ActiveX alls将导致一些麻烦,这很可能是您的
异常的原因。
I think the problem is that the code you run runs in the dll's main procedure. This part of the initialization is very restrictive e.g. you may not load any dll nor you areallowed to call CoInitialize (see http://msdn.microsoft.com/en-us/library/ms678543%28v=vs.85%29.aspx) .Your ActiveX alls there will cause some troubles which are most likely the reason for yourexception.
这篇关于在处理传入请求之前,如何在'TISAPIApplication`中建立ADO数据库连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!