Bad IL format. The Format Of The File 'C:\Users\username\.nuget\packages\uipath.database.activities\1.7.0\lib/net5.0-windows7.0/runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll' Is Invalid.

How to solve "Bad IL format. The format of the file 'C:\Users\username\.nuget\packages\uipath.database.activities\1.7.0\lib/net5.0-windows7.0/runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll' is invalid"?

Issue Description: The error "Bad IL format. The format of the file 'C:\Users\username\.nuget\packages\uipath.database.activities\1.7.0\lib/net5.0-windows7.0/runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll' is invalid" appears in Studio when compiling or publishing a new Windows project or a Windows project converted from a Windows-Legacy project.

Resolution:

Approach #1: This is a known issue in the UiPath.Database.Activities package version 1.7.0 (also observed with 1.7.1) as presented in the package Release Notes.

  • Go to the database activity properties and update the Provider Name from System.Data.SqlClient to Microsoft.Data.SqlClient as shown below:

Note: For Windows - Legacy projects, choose between System.Data.SqlClient or Microsoft.Data.SqlClient.

Approach #2: Follow the steps below,

  1. Delete the Microsoft.Data.SqlClient.SNI.dll file from the directory mentioned in the error message.
  2. Reinstall the UiPath.Database.Activities package via Studio - Manage Packages.
  3. Try running the automation again and see if the error is resolved.

A post was split to a new topic: “Bad IL format. The format of the file ‘C:\Users\username.nuget\packages\uipath.database.activities\1.7.0\lib/net5.0-windows7.0/runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll’ is invalid”

A post was merged into an existing topic: “Bad IL format. The format of the file ‘C:\Users\username.nuget\packages\uipath.database.activities\1.7.0\lib/net5.0-windows7.0/runtimes/win-x64/native/Microsoft.Data.SqlClient.SNI.dll’ is invalid”

A post was split to a new topic: How to resolve errro resolve the error occurring in " UiPath.Database.Activities >= 1.71 UiPath Studio 2023.10.4 "?