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
Solved! Go to Solution.
Use Microsoft.Data.SqlClient. There are a lot of little tweaks with .net 6.
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.
Use Microsoft.Data.SqlClient. There are a lot of little tweaks with .net 6.
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.
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!
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.
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??
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.