The platform is not supported by the System.Data.Odbc package
As I wrote some time ago, we were porting our application to .NET 6. One weird stuff that we were still compiling everything as a .NET Framework application but executing it in .NET 6 runtime.
Pretty much everything works just fine but some 3rd party assemblies do not work because they are using something that is absent in .NET 6. One such assembly was the System.Data.Odbc. And we didn’t reference it as a package and this assembly was simply present in our application directory.
Typically for these cases, I would download a package from nuget.org, open it as a zip archive, then go to the lib directory, find the appropriate version, and replace the version we have in the repository with a new one. In some cases I would take the .NET Standard version and in some .NET 6 version.
It is exactly what I did in this particular case but a little bit later I got a message from QA that this assembly is throwing an exception that the platform is not supported. I tried a different version and it still throws the same error. Then I opened this assembly in ILSpy and I found that absolutely all constructors, methods, and properties throw the “Platform is not supported” exception.
Then I started searching the internet but I found only weird and strange cases. So it looks like it works for everybody else but me. And then I decided to check other directories and then I found the correct library in the runtimes\win\lib\net6.0\System.Data.Odbc.dll directory.
It looks like Microsoft wants to have an assembly that throws an exception when the combination of runtime and OS is unknown and a correct one when this information is known. I think it is because implementations are quite different for different operating systems. I’m not sure if this is correct because an assembly size is almost the same for all operating systems but I think they have a good reason to do it this way.
Anyway, I hope it helps someone.