简体   繁体   English

regsvr32 导致 CDatabase destrucor 在使用 SQL Native Client (v2005) 时挂起

[英]regsvr32 causes CDatabase destrucor to hang when using SQL Native Client (v2005)

I've got a C++ COM dll in Visual Studio 2005 that uses SQL Server (v2000) driver to connect to the database (SQL Server 2005).我在 Visual Studio 2005 中有一个 C++ COM dll,它使用 SQL 服务器 (v2000) 驱动程序连接到数据库 (SQL Server 2005)。 We've recently been tasked by our DB Team to upgrade our SQL Server driver from SQL Server (v2000) to SQL Native Client (v2005) or SQL Server Native Client 10.0 (v2007).我们的数据库团队最近委托我们将 SQL 服务器驱动程序从 SQL 服务器 (v2000) 升级到 SQL 本机客户端 (v2005) 或 SQL 服务器本机客户端 10.0 (v2007)。

Application builds just fine.应用程序构建得很好。 Then, when I go to perform the regsvr32 command on the DLL to register it for COM, the application hangs.然后,当我go在DLL上执行regsvr32命令为COM注册时,应用程序挂了。 When I debugged through the code I found that in the InitInstance of the main APP (which inherits from CWinApp) the application logs a startup message to the database using a stored procedure.当我通过代码进行调试时,我发现在主 APP(继承自 CWinApp)的 InitInstance 中,应用程序使用存储过程将启动消息记录到数据库中。

Debugging into that logging message reveals that a CDatabase object is created which executes the stored procedure.调试该日志消息显示创建了一个 CDatabase object 来执行存储过程。 The stored procedure executes correctly;存储过程正确执行; the message gets logged to the database and execution is returned to the C++ code.消息被记录到数据库中,执行返回到 C++ 代码。 Then, when the CDatabase object is closed (by calling CDatabase::Close()) the application hangs.然后,当 CDatabase object 关闭(通过调用 CDatabase::Close())时,应用程序挂起。 I debugged into the CDatabase code and found that in CDatabase::Close() a call is made to我调试了 CDatabase 代码,发现在 CDatabase::Close() 中调用了

AFX_SQL_SYNC(::SQLFreeConnect(m_hdbc));

It's in this call that the execution does not return.正是在这个调用中,执行不返回。 The debugger goes back to a (Running) state and nothing comes back.调试器返回到 (Running) state 并且没有任何返回。 When I try and do a Debug -> Break All I get a message stating that there are no running threads and that the process may be deadlocked.当我尝试执行 Debug -> Break All 时,我收到一条消息,指出没有正在运行的线程并且进程可能已死锁。

This only happens during the call to REGSVR32.这仅在调用 REGSVR32 期间发生。 And if I choose the Sql Server driver for the regsvr32 portion, then change it to the Sql Native Client or Sql Server Native Client v10.0 the application works just fine.如果我为 regsvr32 部分选择 Sql Server 驱动程序,然后将其更改为 Sql Native Client 或 Sql Server Native Client v10.0,应用程序工作正常。

I'm working with Microsoft on this as well, but we're running out of time.我也在与微软合作解决这个问题,但我们的时间不多了。 Any help or thoughts would be greatly apprecaited!任何帮助或想法将不胜感激!

Thanks,谢谢,

The guy in the link below seem to have solved it by dynamically loading the ODBC dlls in his main APP and not only in the DLL. Could this be somehow applicable in your case?下面链接中的人似乎已经通过在他的主应用程序中动态加载 ODBC dll 来解决它,而不仅仅是在 DLL 中。这是否适用于您的情况?

SQLFreeHandle Deadlock Issue? SQLFreeHandle 死锁问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM