You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System.Data.Odbc v4.7.0 Platform: Windows Server 2019 version 1809 (build 17763.805) Runtime: .NET Core 3.1 (Library with odbc dependency is .NET Standard 2.1) Exception:
System.PlatformNotSupportedException: System.Data.ODBC is not supported on this platform.
at System.Data.Odbc.OdbcConnection..ctor(String connectionString)
at Connector.SysCfg.Odbc.OdbcSysCfgRepository..ctor(String dsnName) in D:\Sync\Repositories-Ipecon\paragon-platform\src\Connector.SysCfg\Odbc\OdbcSysCfgRepository.cs:line 28
...
Additional info:
Just migrated from .NET Framework 4.6.1 to .NET Core 3.1 on the same machine. OdbcConnection worked fine on .NET Framework 4.6.1.
Application is x86.
Ok, I figured out it was because of the .NET Standard, which is not supported. I still see some problems with this though:
It's not the platform that is not supported. I was targeting win-x86 platform which is supported.
I had to go to dotnet/corefx repo, check the System.Data.Odbc.csproj to find out what's going on. On this line:
I also encountered a similar problem
The class library refers to odbc, and the console refers to the dll file, and it will prompt "System.Data.ODBC is not supported on this platform."
Same issue here. I am new to c# and I was trying to make a connection to an sql table to fill a dataset like this
public static DataSet GetDataSetFromAdapter(DataSet dataSet, string connectionString, string queryString)
{
using (OdbcConnection connection =
new OdbcConnection(connectionString))
{
OdbcDataAdapter adapter =
new OdbcDataAdapter(queryString, connection);
// Open the connection and fill the DataSet.
try
{
connection.Open();
adapter.Fill(dataSet);
MessageBox.Show("here u did it");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// The connection is automatically closed when the
// code exits the using block.
}
return dataSet;
}
6.0.1 gives the same error when the project is entirely built in .Net 6.0.
System.PlatformNotSupportedException: System.Data.ODBC is not supported on this platform.
at System.Data.Odbc.OdbcCommand..ctor(String cmdText)
at Signergy.Queries.Installations.GetUpdatedCrewQuery.Run(Int32 since, CancellationToken cancellationToken)
at Signergy.Repositories.CrewRepository.GetCrewModifiedSince(Int32 modifiedSince, CancellationToken cancellationToken)
at ServiceProcess.SignergyAgentProcess.QueryCrew(CancellationToken cancellationToken)
at ServiceProcess.SignergyAgentProcess.LoopingQuery(CancellationToken token)
publicclassGetUpdatedCrewQuery:BaseQuery<IEnumerable<Installation>>{publicGetUpdatedCrewQuery(IDBConnectiondb):base(db){}publicasyncTask<ModifiedSinceResponse<CrewMember,int>>Run(intsince,CancellationTokencancellationToken){varcommand=newOdbcCommand(@" SELECT Installation_crew_members.INSTALLATION_CREW_MEMBERSID AS CrewId, Installation_crew_members.STAFFID AS CrewStaffId, Installation_crew_members.MemberName AS CrewName FROM Installation_crew_members WHERE CrewId > {Since} ORDER BY CrewId ");command.Connection=Connection;command.Parameters.AddWithValue("Since",since);Console.WriteLine("Querying crew since "+since);varreader=awaitcommand.ExecuteReaderAsync(CommandBehavior.SequentialAccess);varresult=newList<CrewMember>();varlastModified=since;varcolumns=newOdbcReaderColumnCache(reader);while(reader.Read()){try{varcrewId=columns.ValueIntFor("CrewId");varcrewMember=newCrewMember(id:crewId,staffId:columns.ValueIntFor("CrewStaffId"),name:columns.ValueStringFor("CrewName"));result.Add(crewMember);if(crewId>lastModified){lastModified=crewId;}}catch(Exceptione){Console.WriteLine("Skipping unreadable crew "+columns.ValueFor("CrewId")+' '+e.Message+' ');}}returnnewModifiedSinceResponse<CrewMember,int>(lastModified,result);}}
@BryanCrotaz I don't know what exactly wrong with your code, but workers build produce runtimes sub-folder with runtime-specific builds. For some reason when you run your program it cannot locate proper runtime for windows and default files from build root used. And they contain netstandard2.0 version of odbc assembly, which always will throw such exception. You should check you don't remove/have windows runtime subfolder
Fixed this issue long ago but here is a little help for anyone new: Fix the issue by matching the System.Data.Odbc package version relative to the dotnet version you are on. Example, if you are on .net 5, go to System.Data.Odbc package and make sure you are also on one of the versions starting with 5.
We are running into a similar issue recently on .NET 10 in combination with a Delphi Application. Our Delphi application loads .NET core plugins. And some plugins use OleDb or ODBC to make database connections.
Adding a RuntimeIdentifier to our plugin project has helped us to solve this issue.
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
I guess this makes sense as it helps the NuGet package to make the correct decision which DLL it should use.
Activity
esso23 commentedon Dec 18, 2019
Ok, I figured out it was because of the .NET Standard, which is not supported. I still see some problems with this though:
It's not the platform that is not supported. I was targeting win-x86 platform which is supported.
I had to go to dotnet/corefx repo, check the System.Data.Odbc.csproj to find out what's going on. On this line:
I think the exception is misleading and should be changed to something else.
ajcvickers commentedon Jun 23, 2020
@esso23 Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.
ligf commentedon Jul 16, 2020
I also encountered a similar problem
The class library refers to odbc, and the console refers to the dll file, and it will prompt "System.Data.ODBC is not supported on this platform."
roji commentedon Dec 16, 2020
This looks like it should no longer be relevant, as there won't be further versions of .NET Standard and libraries are expected to simply target .NET.
Merge pull request dotnet#898 from jkotas/merge-master
ActionNamou commentedon May 21, 2021
Same issue here. I am new to c# and I was trying to make a connection to an sql table to fill a dataset like this
Please let me know how we can fix this error.
Update dependencies from https://github.com/dotnet/arcade build 20220…
MicahKimel commentedon Nov 16, 2022
I am also having this issue in .net5.0, my code is similar to @ActionNamou
roji commentedon Nov 17, 2022
@ActionNamou @MicahKimel which .NET version (TFM) are you targetting? Can you please share your csproj file?
3 remaining items
MaceWindu commentedon Nov 18, 2022
@MicahKimel you should downgrade System.Data.Odbc to v6.0.1 #78550
MicahKimel commentedon Nov 18, 2022
@MaceWindu Sweet Thanks!!
BryanCrotaz commentedon Nov 19, 2022
6.0.1 gives the same error when the project is entirely built in .Net 6.0.
Library project file - Signergy.dll
App project file
BryanCrotaz commentedon Nov 21, 2022
@roji what's wrong with the above app - why is it reporting this error whether running as a cmd line exe or as a service, on Windows 10?
I've tried with x86, Any CPU and x64 with version 7.0 and 6.0.1
roji commentedon Nov 21, 2022
@BryanCrotaz and others, it will probably take me a few more days to look into this, thanks for your patience.
BryanCrotaz commentedon Nov 21, 2022
@roji Emailed you source code in case that helps you diagnose. It fails immediately on startup
MaceWindu commentedon Nov 27, 2022
@BryanCrotaz I don't know what exactly wrong with your code, but workers build produce runtimes sub-folder with runtime-specific builds. For some reason when you run your program it cannot locate proper runtime for windows and default files from build root used. And they contain
netstandard2.0version of odbc assembly, which always will throw such exception. You should check you don't remove/havewindowsruntime subfolderchkrishna2001 commentedon Mar 31, 2023
Is there a fix for this ?, I am getting this error when I use .net 5.0, but works when using .net 6.0
ajcvickers commentedon Mar 31, 2023
@chkrishna2001 .NET 5 is out-of-support.
chkrishna2001 commentedon Mar 31, 2023
@ajcvickers I know, but until we migrate, is there a work around to this ?
ajcvickers commentedon Apr 4, 2023
I'm not aware of any workarounds.
gordon-matt commentedon Jul 1, 2023
Just noticed this issue. Linking to one I recently opened myself: #88281
ActionNamou commentedon Oct 6, 2023
Fixed this issue long ago but here is a little help for anyone new: Fix the issue by matching the System.Data.Odbc package version relative to the dotnet version you are on. Example, if you are on .net 5, go to System.Data.Odbc package and make sure you are also on one of the versions starting with 5.
donnyv commentedon Mar 5, 2024
@ActionNamou That saved me. Thanks!
rikvandenberg commentedon Jan 5, 2026
We are running into a similar issue recently on .NET 10 in combination with a Delphi Application. Our Delphi application loads .NET core plugins. And some plugins use OleDb or ODBC to make database connections.
Adding a
RuntimeIdentifierto our plugin project has helped us to solve this issue.I guess this makes sense as it helps the NuGet package to make the correct decision which DLL it should use.