Inventor 2025 and Microsoft.Data.SQLClient error

Inventor 2025 and Microsoft.Data.SQLClient error

csandersPN6FA
Explorer Explorer
286 Views
4 Replies
Message 1 of 5

Inventor 2025 and Microsoft.Data.SQLClient error

csandersPN6FA
Explorer
Explorer

My company has just upgraded to Autodesk 2025, and like others on this forum, we ran into issues regarding the .net core framework. I've managed to switch everything over successfully, with the only exception being with SQLClient. I have looked through this and other forums for the answer, and it always ends with placing files in the same directory as the .dll. I've added the files and still get this error:

 

Error.png

 

I would appreciate any help. 

 

Thanks

0 Likes
287 Views
4 Replies
Replies (4)
Message 2 of 5

MjDeck
Autodesk
Autodesk

Hi @csandersPN6FA - is this error message coming from a custom add-in that you developed? Or is it a separate EXE that connects to Inventor through COM?

Are you getting Microsoft.Data.SqlClient from Nuget?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 3 of 5

csandersPN6FA
Explorer
Explorer

It comes from a custom add-in. And yes, I'm getting Microsoft.Data.SqlClient from Nuget. For now I'm using the older System.Data.SqlClient, but because it's no longer supported, I'd like to keep everything up-to-date.

0 Likes
Message 4 of 5

MjDeck
Autodesk
Autodesk

When you install your add-in, do you copy Microsoft.Data.SqlClient.dll to the same folder as the add-in DLL?
Are you using C# or VB?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 5

MjDeck
Autodesk
Autodesk

@csandersPN6FA  - with help from another developer I was able to make it work in a C# add-in. The trick is to manually edit the .csproj file and add these lines at the top, after the TargetFramework line:

    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

This is required because Inventor is a 64-bit process, and Microsoft.Data.SqlClient will load its own native DLLs for that architecture.
For more information, see this discussion on StackOverflow.
In addition, make sure you're building a Configuration with a Platform of x64 (not Any CPU). (It's possible that Any CPU would work as well, but I didn't test it.)
With this in place, Visual Studio will build your DLL(s) and put it together with all the required files from the Microsoft.Data.SqlClient package in the subfolder:
bin\x64\Release\net8.0-windows\win-x64

Here's a sample project. It doesn't do anything useful, but it is able to load the required DLLs and try to start an SqlConnection.

I created this project from scratch. If you're modifying an existing project, you might have to:

  • Clean
  • Open a Package Manager Console window and run the command:  dotnet restore
  • Rebuild

Mike Deck
Software Developer
Autodesk, Inc.

0 Likes