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:
Adding the SNI file to the .nupkg package in the path ‘net6.0/runtimes/win-x64/native’;
Adding the SNI file to the .nupkg package in the path ‘net6.0’;
Adding the SNI file and the Microsoft.Data.SqlClient dll to the ‘net6.0’ folder (which I’m pretty sure you should avoid doing)
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.
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.
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
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.
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.