none
"A dynamic link library (DLL) initialization routine failed" Error

    Question

  • This error is occuring on Windows 2003 SP2 64 bit running SQL Server 2008 R2.  I'm using OLE Automation stored procedures to send emails via CDO.  Here is the method I'm using to send the emails.

    http://support.microsoft.com/default.aspx?scid=kb;en-us;312839&sd=tech

    Here is more information from the error.

     

    Source of Failure Description of Failure Output from Failure Comment about Failure
    NULL NULL NULL Failed at sp_OASetProperty sendusing
    CDO.Configuration.1 A dynamic link library (DLL) initialization routine failed.     Description: A dynamic link library (DLL) initialization routine failed.   sp_OAGetErrorInfo for sp_OASetProperty sendusing

    After searching around I'm pretty certain the error is due to a Windows problem and not SQL Server.

    Here is a Windows hotfix that seems to apply however I'm not sure.

    http://support.microsoft.com/kb/941105/en-us

    The few forum thread's I've found say restarting the server will temporarily solve the problem.  Could someone tell me if the hotfix will correct this?

    One other thing.  The support article 941105 lists these file versions.

    File name File version
    Hal.dll 5.2.3790.4225
    Ntkrnlmp.exe 5.2.3790.4225
    Ntoskrnl.exe 5.2.3790.4225

    However, these are the versions on my server.

    File name File version
    Hal.dll 5.2.3790.3959
    Ntkrnlmp.exe 5.2.3790.4666 
    Ntoskrnl.exe 5.2.3790.4666 

    I'm not sure I should install the hotfix since two out of the three that are installed are later versions than mention in the hotfix.

     


    Kevin

    Thursday, May 19, 2011 2:27 PM

All replies

  • The hotfix addresses an issue with availability of TLS slots on the server. If you try to load any DLL, it's initialization will fail if you are facing this issue. However, you first need to check in KB312839 and find out if SMTP is configured correctly on your server. If yes, then try loading any other DLL to see if that fails as well. Trying taking a backup of a dummy database on your SQL instanse using SQL Server Backup Simulator. If you get the error below, then the fix in the KB will help and you are running into the issue mentioned in the KB article:

    Error: 18210, Severity: 16, State: 1.
    BackupVirtualDeviceSet::Initialize: CoCreateInstance failure on backup device 'd4630f27-03a1-47ae-b7a7-4813a6809908'. Operating system error 0x8007045a(A dynamic link library (DLL) initialization routine failed.).

    Also, have you looked at Database Mail. That also uses SMTP to send mail. Is there a specific reason that you are using CDO?

    HTH


    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog: http://www.troubleshootingsql.com
    Twitter: @banerjeeamit
    MSDN Blog: http://blogs.msdn.com/sqlserverfaq
    Sunday, May 22, 2011 5:54 PM
  • Amit,

    I tried the backup simulator and everything seemed to work fine.

    Here's the validation output -

    *************************************************************************
    Connecting to SQL Server instance:MyServer
    *************************************************************************
    OS Platform: 64-bit

    SQL Server Platform: 64-bit

    SQL Server build: 10.50.1765.0

    Current login domain\user is a member of sysadmin in SQL Server.

    VDI dll version used by SQL Server: 2009.100:1600.1
    VDI dll path used by SQL Server: C:\Program Files\Microsoft SQL Server\80\COM\sqlvdi.dll


    Reading build number of sqlvdi.dll files:
    Physical dll file version from \Program Files\Microsoft SQL Server\80\COM
    2009.0100.1600.01
    Physical dll file version from \Program Files\Microsoft SQL Server\80\Tools\Binn
    2009.0100.1600.01
    Physical dll file version from \Program Files (x86)\Microsoft SQL Server\80\COM
    2009.0100.1600.01
    Physical dll file version from \Program Files (x86)\Microsoft SQL Server\80\Tools\Binn
    2009.0100.1600.01

    Build number of all sqlvdi.dll's are matching

    Checking whether SQL Server Virtual Device Interface for Server is registered:
    SQLVDI IID located in HKEY_CLASSES_ROOT\CLSID\
    SQLVDI IID located in HKEY_CLASSES_ROOT\Wow6432Node\CLSID

    Checking whether SQL Server Virtual Device Interface for Client is registered:
    SQLVDI IID located in HKEY_CLASSES_ROOT\CLSID\
    SQLVDI IID located in HKEY_CLASSES_ROOT\Wow6432Node\CLSID

    ****************************************************************************************
       Validation Completed. Please review the validation output above    
    ****************************************************************************************

    Here's the output from the test backup.  It was the same for the 32 bit test.

    Sending command line: Backup MyServer Northwind \ to SQLBackupS.exe

    Processed 448 pages for database 'Northwind', file 'Northwind' on file 1.
    Processed 3 pages for database 'Northwind', file 'Northwind_log' on file 1.
    BACKUP DATABASE successfully processed 451 pages in 0.050 seconds (70.429 MB/sec).
    Connecting to Server: MyServer
    Database used: Northwind
    File location: \
    Performing a BACKUP using a virtual device.

    Trying to perform VDI test on a default instance
    Sending the backup command to the SQL instance...

    Performing data transfer...

    Completed data transfer function.

    MaxTransferSize used (bytes): 65536
    BlockSize used: 512


    The SQL command executed successfully.

    Do you agree then that the hot fix will not address the problem?

    Unless you can think of anything else I will go ahead and begin looking at database mail.  I have jobs, stored procedures, and triggers using the cdo method.  Can database mail be used this way?

    Thanks,


    Kevin


    Wednesday, June 15, 2011 7:45 PM
  • It could be that you are running out of TLS slots. Without analyzing data collected from the server, it would be difficult to state whether the issue will be fixed with the hotfix. If you do not have a reason not to use Database Mail, I would suggest that you use DB Mail to send out the emails. CDO with sp_OAcreate can cause non-BPool memory pressure in case your memory requirements are not sized correctly. Also, if you have a lot of emails, there will be a large number of XProc calls using sp_OAcreate.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog: http://www.troubleshootingsql.com
    Twitter: @banerjeeamit
    MSDN Blog: http://blogs.msdn.com/sqlserverfaq
    Friday, June 17, 2011 6:42 PM
  • Amit,

    In fact we use sp_OACreate quite a lot for other things besides sending emails with CDO.  Our third party ERP system provides COM objects for posting transactions.

    How would I see evidence of memory pressure?  Our server has 8 GB of memory and SQL is set with min of 3 GB and max of 4 GB.  Performance monitor shows 1.5 GB of memory available.

    This may be getting off topic (but maybe not), I'm following our third party examples for executing sp_OACreate.  They show using an execution context value of 5.  Should I be using 4?  If it makes a difference, the ERP software is installed on the same server as SQL Server.  Here's the explanation of sp_OACreate that makes me ask the question.

    http://technet.microsoft.com/en-us/library/aa238863(SQL.80).aspx

    Thanks for your help,

    Kevin

     


    Kevin
    Monday, June 20, 2011 1:37 PM
  • Using a context value of 4, lets you load the COM object outside of SQL address space. When you load COM objects in SQL address space, then the non-Buffer Pool portion gets used. On a 64-bit server, if you are facing memory pressure, then you would need to back off your Max Server Memory.

    Reference: http://troubleshootingsql.com/2010/05/26/non-bpool-region-on-64bit-sql-instances-may-be-larger-than-you-think/

    However, in your case, I think it's more to do with you running out of TLS slots and the KB fix mentioned above should help. If it is a TLS slot exhaustion issue, then sizing your max server memory won't help.

    HTH


    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog: http://www.troubleshootingsql.com
    Twitter: @banerjeeamit
    MSDN Blog: http://blogs.msdn.com/sqlserverfaq
    Monday, July 04, 2011 7:20 PM