Getting exception while consuming Interop.SQLXMLBULKLOADLib.dll library to bulk upload the data in C# Application with .NET 4.7 Framework on TLS 1.2 enabled setup

Satish Karambalkar 1 Reputation point
2022-08-30T14:29:44.317+00:00

We are getting exception while consuming Interop.SQLXMLBULKLOADLib.dll library to bulk upload the data in C# Application with .NET 4.7 Framework.

Details of library used for bulk upload:
Interop.SQLXMLBULKLOADLib.DLL
RunTime version: v1.1.4322
Version: 4.0.0.0

Following method we are calling to do the upload operation:

public virtual extern void Execute(string bstrSchemaFile, object vDataFile)

Note: We are using provider as "MSOLEDBSQL" while forming SQL connection string.

The Error we are getting from the server:
System.Runtime.InteropServices.COMException (0x80004005): Error connecting to the data source.
at SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class.Execute(String bstrSchemaFile, Object vDataFile)

Environment Details:

Windows 2016
SQL verion - 2016 Service Pack 2
TLS 1.2 is enabled on Windows

Following are the steps to enable TLS 1.2 on the windows server.
a. Disable TLS 1.0 and 1.1 - Best Crypto Security Win 2016, 2019 rev 4
b. Disables TLS 1.0 and 1.1 (enables 1.2) for the Windows OS
c. Makes .NET Framework compatible with TLS 1.2
d. Configures the WINHTTP protocol to disable TLS 1.0 and 1.1 (enables 1.2)
e. Disables TLS 1.0 and 1.1 in Google Chrome, Microsoft Edge Chromium and Internet Explorer. (Internet Explorer is also dependent on the Windows OS TLS configuration, the Chromium browsers are not.)
f. Forces .NET Framework to use Strong Crypto
g. Disables RC4 crypto for the Windows OS
h. Disables Triple DES crypto for the Windows OS
i. Disables DES crypto for the Windows OS
j. Configures DHE (Diffie-Hellman) TLS to use 2048 bit key exchange to close two iPost vulnerabilities.
k. Forces the Windows OS to enforce FIPS 140-2 compliance for crypto.
l. Defines what ciphers suites are enabled and the order of the cipher suites for the TLS handshake. THIS VERSION DISABLES MORE WEAK CIPHERS THAN THE “Good Crypto” version. This version is for 2016 and 2019 and is not compatible with earlier versions of Windows Server.

Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,368 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,248 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,105 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,118 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 55,196 Reputation points
    2022-08-30T20:18:12.843+00:00

    does the sqlserver have a trusted certificate? if not you need to add TrustServerCertificate=True to connection string.

    0 comments No comments

  2. Limitless Technology 39,341 Reputation points
    2022-09-02T07:55:54.753+00:00

    Hi, Satish,

    I know I did something that raised this error message once, but (as often happens) the problem ended up having nothing to do with the error message. Not much help, alas.

    Some troubleshooting ideas: try to determine the actual SQL command being generated and submitted by the application to SQL Server (SQL Profiler should help here), and run it as "close" to the database as possible--from within SSMS, using SQLCMD, direct BCP call, whatever is appropriate. Detailing all tests you make and the results you get may help.

    -----------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments