Hello everyone,
I have migrated my customization project to AutoCAD Plant 3D 2025 / net8. After that, the System.Data.Odbc package from Microsoft no longer works. I get the error message: PlatformNotSupportedException. To rule out problems caused by the migration, I have carried out the following steps:
Without AutoCAD:
1. created a new Windows Form App (VB) in Visual Studio 2022 “TestODBCWinFormsApp” ( .NET 8 long term support)
2. added a button to the form
3. added a Button1_Click
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myConnection As System.Data.Odbc.OdbcConnection = New System.Data.Odbc.OdbcConnection()
End Sub
4. added System.Data.Odbc from Microsoft Version 8.0.0 via the NuGet Manager
5. project created and executed: No exception is thrown
With AutoCAD:
1. add existing project from AutoCAD Plant 3D 2025 SDK: ..\AutoCAD Plant 3D 2025 SDK\samples\dotNet\HelloWorld\HelloWorld.vbproj
2. added a button to the “HelloWorldForm”
3. added a Button1_Click
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myConnection As System.Data.Odbc.OdbcConnection = New System.Data.Odbc.OdbcConnection()
End Sub
4. added System.Data.Odbc from Microsoft Version 8.0.0 via the NuGet Manager
5. project created
6. start AutoDesk Plant 3D 2025, open a drawing
7. loaded the HelloWorld.dll with NETLOAD
8. execute the “helloform” command and click on the new button
************** Ausnahmetext **************
System.PlatformNotSupportedException: System.Data.ODBC is not supported on this platform.
at System.Data.Odbc.OdbcConnection..ctor()
at HelloWorld.HelloWorld.HellowWorldForm.Button1_Click(Object sender, EventArgs e) in R:\SKL\Autodesk\AutoDeskSDKs\AutoCAD Plant 3D 2025 SDK\samples\dotNet\HelloWorld\HelloWorldForm.vb:line 98
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
I have attached the entire error message as an attachment.
Do you have any ideas?
Have fun testing!
Greetings Lars
Solved! Go to Solution.
Solved by kdub_nz. Go to Solution.
what is at this line ??
SDK\samples\dotNet\HelloWorld\HelloWorldForm.vb:line 98
Though it does look as though this is your issue to rectify:
System.PlatformNotSupportedException: System.Data.ODBC is not supported on this platform.
Perhaps start here :
added:
Looking at your error.txt file
ping: @moogalm
This may need to be addressed by Autodesk ( if they provided the referenced file )
---------------------------------------- System.Data.Odbc Assemblyversion: 8.0.0.0 Speicherort: c:\program files\autodesk\civil 3d 2025 object enabler\System.Data.Odbc.dll ----------------------------------------
// Called Kerry in my other life.
Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.
class keyThumper<T> : Lazy<T>; another Swamper
Thank you for the quick reply.
Unfortunately, I forgot to mention in my post that I have been working on this problem again and again for over a week. I have already used Google. It was always about the .Net version not matching the ODBC package. So I did the test without AutoCAD in a Windows forms app and ran it successfully. Only as a class library in conjunction with AutoCAD it does not work.
added:
Looking at your error.txt fileping: @moogalm
This may need to be addressed by Autodesk ( if they provided the referenced file )
---------------------------------------- System.Data.Odbc Assemblyversion: 8.0.0.0 Speicherort: c:\program files\autodesk\civil 3d 2025 object enabler\System.Data.Odbc.dll ----------------------------------------
This hint was important to recognize the real problem. While running AutoCAD, my class library does not use the System.data.odbc.dll (A) with which my class library was created, but the one under “Civil” (B). I have now copied the System.data.odbc.dll (A) directly under “C:\Program Files\Autodesk\AutoCAD 2025”. The creation of the ODBC connection then worked.
But:
- Is this the right way?
- Does it have other effects?
Many thanks for the hint
Greetings Lars
Thank you very much.
After about four months of trying to convert my application to version 2025 (.NET 8), only today after seeing what was written here, I was able to run the application.
The application uses several connections to databases, one of which is ODBC, which should be the basic form in the Windows environment does not function from within the AutoCAD plugin.
I tried different versions of Odbc Nuget
System.Data.Odbc.dll
including what it depends on:
System.Text.Encoding.CodePages.dll
Even Publish does not copy System.Text.Encoding.CodePages.dll to the directory.
Only after I copied the two DLLs into the AutoCAD 2025 directory did things work.
C:\Program Files\Autodesk\AutoCAD 2025\System.Data.Odbc.dll
C:\Program Files\Autodesk\AutoCAD 2025\System.Data.Odbc.dll_COPY_BY_ME.txt
C:\Program Files\Autodesk\AutoCAD 2025\System.Text.Encoding.CodePages.dll
C:\Program Files\Autodesk\AutoCAD 2025\System.Text.Encoding.CodePages.dll_COPY_BY_ME.txt
I found a definition in the .csproj project file that copies all the files the project needs when the project is a DLL:
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#copylocallockfileassemblies
@kdub_nz - Sorry I didn't see the ping.
If your plugin uses third-party dependencies, I recommend using the
dotnet publish
This will copy all dependencies alongside your DLL, which is useful for applications loaded through the Autoloader bundle mechanism. Alternatively, you can edit your .csproj
file and add the CopyLocalLockFileAssemblies
property. Both methods ensure the AutoCAD runtime can find these dependencies relative to the loaded DLL.
Hi @moogalm,
thanks for your respone. But I see a ping. Why I have to use a third-party. Why can't I use this dll?
c:\program files\autodesk\civil 3d 2025 object enabler\System.Data.Odbc.dll
Is the development environment for CIVIL not yet at the level of Plant 3D?
Greetings
Lars
According to what I read, the .NET mechanism first checks if the DLL is already loaded, if not it loads the one that is close to the one that requires it.
Just check that all the DLLs are really in your Output directory
Also of NuGet that sits in a central place of your computer!
At least for me, with Civil 3D, it seems to work.
See if this helps . . .
https://adndevblog.typepad.com/autocad/2024/05/connecting-to-sql-server-from-autocad-2025.html
// Called Kerry in my other life.
Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.
class keyThumper<T> : Lazy<T>; another Swamper
Hello
AutoCAD continue using System.Data.SqlClient.dll and not moved to Microsoft.Data.SqlClient.dll !
And System.Data.OleDb.dll is ver. 6 not 8!
On Civil 3D, we have two System.Data.OleDb.dll, ver 6 and 8:
The size of System.Data.Odbc.dll that in C3D directory is small!! 99kb not like "my" dll 290kb:
Autodesk seems to have copied the wrong DLL file and also there is probably a problem with the location when we are not running Civil 3D.
Hi kdub_nz, Izhar_Azati, moogalm,
thanks for your support. I will close the problem. The solution for me came from the hint that I used the wrong DLL (c:\program files\autodesk\civil 3d 2025 object enabler\System.Data.Odbc.dll) from C3D object enabler. That's why I always copy the correct version now.
Best regards
Lars
Can't find what you're looking for? Ask the community or share your knowledge.