Friday, February 24, 2012

Import a COM+ application That depends on SQLNCLI on 32 bit XP Fails.

We have a 32 bit COM+ application that depends on SQLNCLI.DLL for BCP functionality. We are upgrading to the SQL Server Native client and moving away from ODBCBCP.dll.

Anyone running 32 bit XP attempting to import the COM+ application gets the following message: The DLL could not be loaded. Check to make sure all required application runtime files and other dependent DLLs are available in the component DLL's directory or the system path.

If I revert the DLL back to using ODBCBCP.dll the application will import and run fine. Here is the interesting part. If I import the application with the ODBCBCP.dll then rebuild the DLL so it links against SQLNCLI.DLL the app will run fine. It has no problem finding and loading SQLNCLI.DLL along with all of it's dependencies.

Anyone running 64 bit XP can import the COM+ application when the DLL is linked against SQLNCLI.DLL.

Does anyone have any insight into this issue. It is causing our developers alot of headache. If sample code is needed I will be glad to provide it, but only at request.

Thanks for your time,
Mike

To use the bcp APIs you have to link with a .lib that has the bcp API entry points because they are not accessed through the driver manager like mainstream ODBC APIs. With the MDAC 'SQL Server' driver you have to link with odbcbcp.lib and the bcp APIs are in a seperate odbcbcp.dll. With 'SQL Native Client' you have to link with sqlncli.lib - for SQL Native Client we put everything into a single dll - APIs, bcp and netlibs. If an app is linked with odbcbcp.lib but loads sqlsrv32.dll (or links with sqlncli.lib and loads sqlsrv32.dll) then you get an error when you load the app.

This is covered in Books Online in the topic which deals with upgrading applicatsion from MDAC to SQL Native Client(http://msdn2.microsoft.com/en-us/library/ms131035.aspx), which says:

"SQL Native client is not compatible with odbcbcp.dll. Applications which use both ODBC and bcp APIs must be rebuilt to link with sqlncli.lib in order to use SQL Native Client."

Applications which use only the 'standard' ODBC calls only link with the driver manager (odbc32.dll) so don't have a dependency on the driver dll (or bcp dll).

|||I was aware of that and made sure that our entire app only linked with sqlncli.lib. I changed that DLL to be delay loaded and our problem went away and the app runs fine.

No comments:

Post a Comment