Migration Guide: .Net Framework to AutoCAD 2025/.NET 8.0

Migration Guide: .Net Framework to AutoCAD 2025/.NET 8.0

_gile
Consultant Consultant
27,074 Views
69 Replies
Message 1 of 70

Migration Guide: .Net Framework to AutoCAD 2025/.NET 8.0

_gile
Consultant
Consultant

I tried to write a basic step by step migration guide in French. If anyone has the courage to translate it into proper English (I can provide the .docx file if needed)...



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

27,075 Views
69 Replies
Replies (69)
Message 41 of 70

gleeuwdrent
Advocate
Advocate

Thanks, clear for me. I will look to the best solution, because my projects consist of hundreds of files, so linking each file will be a big job, and adding the conditional compilation symbols to each file too. I think I will write a script for this.

0 Likes
Message 42 of 70

_gile
Consultant
Consultant

@gleeuwdrent wrote:

Thanks, clear for me. I will look to the best solution, because my projects consist of hundreds of files, so linking each file will be a big job, and adding the conditional compilation symbols to each file too. I think I will write a script for this.


If you use the Migration Assistant (following the step by step guide) the files will automatically be linked, and you'll only have to add conditional compilation symbols to the files you need/want to make different from the original one.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 43 of 70

gleeuwdrent
Advocate
Advocate

Nice, thanks. I will investigate in it.

0 Likes
Message 44 of 70

Ed__Jobe
Mentor
Mentor

@gleeuwdrent wrote:

Nice, thanks. I will investigate in it.


When running the Uprgrade Assistant, be sure to choose the option to create a copy of the solution. That way, if you don't like the results, you still have your original solution. Either that, or make a copy of your solution and upgrade that one.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 45 of 70

mlobzun
Explorer
Explorer

Hello,

 

Just wanted to share some experience with a support of AutoCAD Plant 2025 in cases where you have to support multiple AutoCAD Plants' in a scope of one solution.

 

It is possible to have one project in a solution that works both with .NET Framework and .NET Core by doing this:

1) Upgrade your project to .NET (Core) 8.0. See the instructions above.

2) Open .csproj file 

3) Change the <TargetFramework>net8.0<\TargetFramework> to <TargetFrameworks>net48;net8.0<\TargetFrameworks>

 

In case you will try to build this project, then you will have two output directories: "bin\net48" and "bin\net8.0". Accordingly, there will be two .dll files, one for each framework. This resolution works great as soon as there is no binary compatibility between AutoCAD Plant 2025 and older versions.

 

Afterwards, it will be possible to change .csproj to reference required .dll files based on a required configuration. For example:

<ItemGroup  And '$(TargetFramework)' == 'net48'">

 <!--Reference old AutoCAD Plant API .dll files-->

</ItemGroup>

<ItemGroup  And '$(TargetFramework)' == 'net8.0'">

 <!--Reference new AutoCAD Plant API .dll files-->

</ItemGroup>

 

The only drawback of this approach is that you will not be able to use new features of the C# language. (Sorry for the quality of the image):

mlobzun_0-1714119136074.png

 

Message 46 of 70

JamesMaeding
Advisor
Advisor

Can anyone comment on why Core net is better than before?

I program for windows desktop and acad/bcad, so don't follow the drama on net framework through time.

I'm guessing it has to do with windows or something, but I'd like to know if advantages.

thx


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Message 47 of 70

_gile
Consultant
Consultant

@JamesMaeding wrote:

Can anyone comment on why Core net is better than before?

I program for windows desktop and acad/bcad, so don't follow the drama on net framework through time.

I'm guessing it has to do with windows or something, but I'd like to know if advantages.

thx


With .NET 8.0, we're moving from C#7 to C#12 with a host of new features and enhancements.

See this topic.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 48 of 70

c_desbaux
Observer
Observer

Hello,

 

I'm very new to ObjectArx, so thanks in advance for your help.

I've created a simple "hello world" class and it built correctly. I try uploading the dll file via APPLOAD on Autocad 2025 but it doesn't seem to accept dll (only .arx, .crx, .lsp etc...).

Could you shed some light on how to run my plugin on Autocad 2025 once it's built?

 

Thank you! 

0 Likes
Message 49 of 70

_gile
Consultant
Consultant

Hi,

To load a .NET plugin in AutoCAD you have to use the NETLOAD command.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 50 of 70

c_desbaux
Observer
Observer

It worked! Thank you very much!

0 Likes
Message 51 of 70

mehul_gidwani
Community Visitor
Community Visitor

Hello, @_gile 
I have followed all steps from the migration guide, and it was very helpful, I was able to resolve most errors and was able to build the plugin for .NET 8 Core and it gets build without errors,
In my previous plugin which compatible AutoCAD 2024 (.NET 4.8 framework), I used System.Data.dll assembly for creating SQL connection, after using Upgrade assistant I installed System.Data.SQLClient nuget Package. 
But as you can see in screenshot below it is looking for the assembly file. 

mehul_gidwani_1-1719308148832.png

 

I am not able to resolve this error as 
1. I am using this as a Package and in .csproj file I have its Reference.
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
2. At the location where the package files get saved, I have the System.Data.SqlClient.dll file but its version is 4.8.6
(i.e package version), Downgrading the package version also doesn't help.

Any suggestion will be highly appreciated.

Thanks


0 Likes
Message 52 of 70

_gile
Consultant
Consultant

@mehul_gidwani 

See if this topic helps.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 53 of 70

norman.yuan
Mentor
Mentor

Firstly, you might as well use Microsoft.Data.SqlClient, as the link provided by @_gile . The change from System.Data.SqlClient to Microsoft.Data.SqlClient would mostly just a Nuget package change, the code would be mostly remain the same.

 

Secondly, beside add "<RuntimeIdentifier>win-x64</RuntimeIdentifier>" to the *.csproj file, you also need to add

 

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

 

this would make sure the DLLs in the Nuget package will be outputted into the AutoCAD plugin's DLL output folder whenever the project is compiled. Instead, You can also use<EnableDynamicLoading>true</EnableDynamicLoading>. The two project settings have subtle differences, but one of it is needed since our Acad .NET API project is a plugin type of app (a DLL outpout), not an EXE app, which is compiled with the Nuget DLLs automatically placed in the EXE folder or ".\runtime\[platform]" folder that the EXE can find them automatically.

 

One bad thing of using Microsoft.Data.SqlClient, while it is recommended for .NET Core/8 desktop app, is the package come with many dependency DLLs. Your AutoCAD plugin may be very light with minimum SQL Server data access requirement, but the Acad plugin would become a big package with a lot of DLLs in it. Nowadays, with current technology trend, direct connection to database server is not recommended, the data should be exposed via services (commonly HTTPs services). In this case, you use HttpClient (Nuget package System.Net.Http) to access data from Acad plugin, only one DLL is needed (System.Net.Http.dll).

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 54 of 70

cesar_mayorine362SG
Contributor
Contributor

You're absolutely right!

I have tested if the Pligins in 4.8 work in autoCAD 2025 and they do.

I have also developed a plugin in Core 8.0 for AutoCAD 2025 with AutoCAD.Net.Core(25.0.0) and it works.

I miss or do not find the possibility to start AutoCAD from Visual Studio in a Core project.

"Start external programm:  C:\Program Files\Autodesk\AutoCAD 2022\acad.exe"

I have not found the libraries for AutoCAD Architecture for .Net Core either.

 

Can you help me with this?

 

 

0 Likes
Message 55 of 70

_gile
Consultant
Consultant

@cesar_mayorine362SG  a écrit :

I miss or do not find the possibility to start AutoCAD from Visual Studio in a Core project.

"Start external programm:  C:\Program Files\Autodesk\AutoCAD 2022\acad.exe"


With .NET 8.0, this have to be done in a json file in the Properties ditectory of the solution: "Properties.launchSettings.json" (create the file if it does not exists). You can get some inspiration from this template.

You can also set this from the project Properties > Debug > Open debug launch profiles UI > Executable.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 56 of 70

kgallagherCGHDN
Advocate
Advocate

I have gone through the upgrade process, when i build the project i get.

 

Severity Code Description Project File Line Suppression State Details
Error (active) BC30652 Reference required to assembly 'AcJsonSerializable, Version=25.0.0.0, Culture=neutral, PublicKeyToken=null' containing the type 'IJsonSerializable'. Add one to your project.

 

I am sure i am missing something. 

 

Thanks in advance.

0 Likes
Message 57 of 70

edvance0108
Contributor
Contributor

Doing some recent research on the matter I came across this excellent 2 part blog post I wanted to make sure got linked here.

Incredibly helpful.

 

Part I - focused on C++/CLI solution migration:

https://forum.techsoft3d.com/t/how-to-migrate-an-autocad-based-application-to-net-core-8-0-part-i/36...

 

Part II -  focused on C#/VB solution migration:

https://forum.techsoft3d.com/t/how-to-migrate-an-autocad-based-application-to-net-core-8-0-part-ii/3...

0 Likes
Message 58 of 70

Pankaj_DEWANI
Observer
Observer

Hi,

 

For my .NET Framework 4.8 DLL, I followed all the steps mentioned in this doc & I could successfully migrate my DLL to .NET 8.0. However, trying to get the DLL registered, I am facing error below:

 

Error (active) MSB3217 Cannot register assembly "<FULLPATH_TO_MYDLL>". Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

 

Has someone faced similar problem? Any suggestions to resolve it?

 

PS.

  1. Included below tag in my csproj file to register the dll:

    <RegisterForComInterop>true</RegisterForComInterop>

 

  2. .NET 8.0 SDK was installed from official microsoft website.

 

Thanks in advance,

Regards,

Pankaj

0 Likes
Message 59 of 70

imranGJ2WC
Contributor
Contributor

Check the following screenshot. This may help you.

 

imranGJ2WC_1-1729773276999.png

 

 

 

 

0 Likes
Message 60 of 70

mszanto
Enthusiast
Enthusiast

Gilles, Jeff,

 

Thank you for providing the upgrade document, it was very helpful.
I've added additional steps, below, that may help others.

 

  1. If you plan to choose the In-Place Upgrade option, backup the AssemblyInfo.cs file from each project's Properties folder to a location outside of the solution folder. The assembly information will be lost during the upgrade therefore you'll need to restore it after the upgrade is complete.

  2. Update PackageContents.xml
    Set SeriesMin and SeriesMax to R25.0
    Update all settings that reference the previous AutoCAD version.

  3. By default, the upgraded project's output path will reflect the target framework therefore, the new output path will be bin\Debug\net8.0-windows. If you prefer the output path to be bin\Debug, edit the .csproj file and add the following settings to the end of the first PropertyGroup in the .csproj file.
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>

  4. Copy the backed up AssemblyInfo.cs files from Step 1 to the Properties folder of the upgraded project(s).
    The file should show up automatically in solution explorer.
    NOTE: Although you can add the assembly information to the project in the Package section of the project properties dialog, it's very cumbersome and will not work without modifying the .csproj file and setting GenerateAssemblyInfo to true.
    For these reasons, it's easier to copy the AssemblyInfo.cs file from the previous project.

  5. If you use PreBuild or PostBuild events, they will no longer work therefore you will need to
    migrate the the PreBuild and PostBuild events using the following steps.
    1. If the project's Properties dialog is open, close it, otherwise, the changes in the steps below may not work.
    2. Edit the .csproj file by double-clicking the project in Solution Explorer.
    3. Scroll to the end of the file and copy the PreBuildEvent and PostBuildEvents
      then paste the copied content into a new text file as a backup.
    4. Delete the PreBuildEvent and PostBuildEvent elements from the .csproj file
      including their surrounding PropertyGroup elements
      then save the changes.
    5. Open the properties of the project in Solution Explorer.
    6. Select the Build > Events tab.
    7. Copy the PreBuild event from the backup created in Step e.
      but don't include the PreBuildEvent or PostBuildEvent tags.
    8. Paste the copied text into the Pre-build event text box.
    9. Repeat the process for the PostBuild event.
    10. Save the changes.
    11. Verify the changes by editing the .csproj file and scrolling to the end.
      The PreBuildEvent and PostBuildEvent elements will reflect the new
      format for the events. For example:
          <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
              <Exec Command="rem Do something" />
              </Target>

  6. If you load settings from an App.config file, you will need to downgrade the System.Configuration.ConfigurationManager package otherwise the following exception will occur while loading the settings.

    System.Configuration.ConfigurationManager 9.0.0 exception:
    System.TypeInitializationException: The type initializer for 'PPWR.AutoCADPlugin.Globals' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. File name: 'System.Configuration.ConfigurationManager, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

    Right-click on Dependencies in the Solution Explorer and select Manage NuGet Packages then select the Installed tab and search for System.Configuration.ConfigurationManager.
    Change the version to 8.0.1 or something prior to 9.0.0 then click Update.