Delphi 10.3
我有一个Datasnap Webbroker应用程序,它已经正常运行了6个月。现在它对请求的响应是"coinitialize没有被调用“。这是相同的exe。我不认为它正在运行的机器或它连接到的SQL机器有任何更改。我们尝试在代码中的不同位置添加coinitialize调用,但这并没有防止错误。
我不确定下一步该怎么做。谢谢。
发布于 2021-07-02 21:13:52
我找到一位专家解决了这个问题。谢谢你奥拉夫·莫尼安
我们仍然不清楚这个项目是如何在没有这个代码的情况下工作了这么长时间,然后突然停止工作的。
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;https://stackoverflow.com/questions/68212280
复制相似问题