德尔福 10.3
我有一个运行良好 6 个月的 Datasnap Webbroker 应用程序。现在它以“尚未调用coinitialize”响应请求。这是同一个exe。我认为它运行的机器或它连接的 SQL 机器没有任何变化。我们已经尝试在代码的不同位置添加 coinitialize 调用,但这并没有阻止错误。
我不确定下一步该尝试什么。谢谢你。
我找到了一个专家来解决它。谢谢你,奥拉夫莫尼恩。
我们仍然不清楚这个项目是如何在没有这段代码的情况下工作这么长时间然后突然停止工作的。
uses Winapi.ActiveX...
constructor TWebMod.Create(AOwner: TComponent);
begin
//om: make sure Coinitialize get called *before* any ADO component is created
//Important: in Webbroker, *every* request creates its own instance of TWebMod - in a worker thread!
//During construction ADO components are created, which will lead to an error,
// if done in a worker thread - if CoInitialize is NOT called before.
CoInitializeEx(nil, Coinit_multithreaded);
inherited;
end;
destructor TWebMod.Destroy;
begin
inherited;
CoUninitialize; //om: uninitialize when done
end;