UiPath Custom activity with Microsoft.Data.SqlClient

Hello all,

I am currently designing a custom activity which requires an interaction with an SQL database. As such, I have added the ‘Microsoft.Data.SqlClient’ dependency to my project.

I have researched plenty of topics online and it seems that there is an issue with loading a dependency, namely, the ‘Microsoft.Data.SqlClient.SNI.dll’ file.

I have tried multiple approaches, such as:

  1. Adding the SNI file to the .nupkg package in the path ‘net6.0/runtimes/win-x64/native’;
  2. Adding the SNI file to the .nupkg package in the path ‘net6.0’;
  3. Adding the SNI file and the Microsoft.Data.SqlClient dll to the ‘net6.0’ folder (which I’m pretty sure you should avoid doing)
  4. Not adding the SNI file and only adding the ‘Microsoft.Data.SqlClient’ package as dependency.

Despite multiple tries with the dependencies, every attempt results in a variant of this error in UiPath Studio, after adding the custom activity:

The type initializer for ‘Microsoft.Data.SqlClient.TdsParser’ threw an exception
System.TypeInitializationException: The type initializer for ‘Microsoft.Data.SqlClient.SNILoadHandle’ threw an exception.\r\n —> System.DllNotFoundException: Unable to load DLL ‘Microsoft.Data.SqlClient.SNI.dll’ or one of its dependencies: The specified module could not be found.

Is there any way to solve this issue?

Thank you

@DM1,

Tried this solution?

Thanks,
Ashok :slight_smile:

@DM1

Please check this

Cheers

Hello @Anil_G, I have indeed tried this, did not work either.

@ashokkarale, I had checked that post before as well and I tried setting the dll in the nupkg in the same way as the database activities shown in that post. Still not able to fix the issue.

@DM1

Are you getting the error while installing the package itself? Or while running?

Cheers

The error occurs while running the activity. All the unit tests pass on Visual Studio, so the issue is caused by some other issue on Studio.

@DM1

What version are you on?

Fid you try with the latest versions?

Cheers

I have tried with both versions 5.2.1 (latest) and 4.1.0 (the one that UiPath uses on package version 1.7.1 of the UiPath.Database.Activities) of Microsoft.Data.SqlClient.

I have also tried deplying on Studio version 2024.10.1 and 2023.10.2

1 Like

I can’t seem to find any official documentation on this issue, nor a proper solution on the forums. We will probably discontinue these custom activities going forward.

Thank you

Spent a fair while on this one.

Seems there is some kind of issue with Studio loading the SNI dll.

The UiPath database activities have manual workarounds in code to load the library if its a windows machine. You could pull their activity pack into your project or pinch their source code if you were so inclined.

Bit of a pain but I’m not sure if its UiPath specific or if its a result of other stuff… seemed to be a lot of discourse about EF6 to EFCore6 and the need for external dependencies.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.