Select to view content in your preferred language

Addin Module error: System.Data.SqlClient is not supported on this platform

6003
7
Jump to solution
07-11-2022 04:02 PM
PeteVitt
Occasional Contributor III

I'm using ArcGIS Pro SDK version 3.0 in Visual Studio 2022. I've loaded the System.Data.Client Package version 4.8.3 from NuGet Package Manager into my ArcGIS Pro Module Add-in project. The issue I'm having is that I'm getting an error: 'System.Data.SqlClient is not supported on this platform' when I try to use a System.Data.SqlClient.SqlConnection object.

     static string sConn = "workstation id=GIS6;packet size=4096;user id=xxx;password=xxxx;data        source=XXXXX;persist security info=False;initial catalog=XXX";
     SqlConnection Conn = new SqlConnection(sConn);

This code works without error if I run it in a Visual Studio 2022 Windows Forms project with the same identical System.Data.Client Package version 4.8.3 loaded.  Any ideas of how I might fix this error?

There's a similar issue described here: https://community.esri.com/t5/arcgis-pro-sdk-questions/add-in-fails-with-quot-the-specified-module-c... but in this issue ArcGIS Pro 2.8 sdk and Visual Studio 2022 is used. 

The connection string code was working fine for me at ArcGIS Pro sdk 2.9 Visual Studio 2017

Thanks

Pete

 

0 Kudos
2 Solutions

Accepted Solutions
MichaelSnook
Occasional Contributor III

Use Microsoft.Data.SqlClient. There are a lot of little tweaks with .net 6.

View solution in original post

CharlesMacleod
Esri Regular Contributor

I did a quick google of "system.data.sqlclient .net 6". This seemed (to me at least) to be one of the more promising links:

https://makolyte.com/system-data-sqlclient-is-missing-in-a-dotnet-core-project/

It recommends including the System.Data.SqlClient nuget package. That's where I would start.

 

View solution in original post

0 Kudos
7 Replies
MichaelSnook
Occasional Contributor III

Use Microsoft.Data.SqlClient. There are a lot of little tweaks with .net 6.

CharlesMacleod
Esri Regular Contributor

I did a quick google of "system.data.sqlclient .net 6". This seemed (to me at least) to be one of the more promising links:

https://makolyte.com/system-data-sqlclient-is-missing-in-a-dotnet-core-project/

It recommends including the System.Data.SqlClient nuget package. That's where I would start.

 

0 Kudos
PeteVitt
Occasional Contributor III

there was a reply suggesting to use Microsoft.Data.SqlClient instead of System.Data.SqlClient.  That reply seems to have been removed from the thread somehow, but the suggestion worked!

0 Kudos
CharlesMacleod
Esri Regular Contributor
I'm not sure why my reply was deleted. This was the original resource I discovered (and referenced):
https://makolyte.com/system-data-sqlclient-is-missing-in-a-dotnet-core-project/

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

You can also look at this example (from community samples) which is using the Microsoft.Data.SqlClient NuGet in its plug-in project:   ProSqlExpressReader solution

I recommend searching the community samples GitHub repository for the specific class that you want to use, in this case I searched for "SqlConnection" and you will get a hit if samples are using that class.

0 Kudos
BrianBulla
Regular Contributor II

Hi,

I am running into this same problem in a project that I am converting from Pro 2.x to Pro 3.  I originally added the NuGet package for Microsoft.Data.SqlClient, but that didn't help at all, and once I added the NuGet fro System.Data.SqlClient that at least removed all the Build errors and I could run the code in debug mode.

But....once I get to the following line of code, I get the "not supported on this platform" error.  Any ideas??

BrianBulla_0-1676491078180.png

 

0 Kudos
BrianBulla
Regular Contributor II

OK, this seems to be working now using the Microsoft.Data.SqlClient NuGet.  Not sure why it's working today but not yesterday.  I've installed/uninstalled several times and now it's working??

Dunno....but it's working with no code changes.....just the NuGet and a new "using" statement.