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

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

_gile
Consultant Consultant
27,050 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,051 Views
69 Replies
Replies (69)
Message 21 of 70

imranGJ2WC
Contributor
Contributor

After Migration as suggested by @_gile , it migrated successfully. The converted project is recompiled successfully and even loaded using NetLoad. But the WPF Modal Windows are not working. It shows the following message on AutoCAD 2025. 

imranGJ2WC_0-1712398239956.png

On the other hand, the WinForm works well. 

var dia = new testFRM();

var result = AcAp.ShowModalDialog( dia);

But the following code shows the above message about cer-dialogue.exe and a runtime exception.
Any Idea about this ?

0 Likes
Message 22 of 70

_gile
Consultant
Consultant

@imranGJ2WC Have a look at this page.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 23 of 70

imranGJ2WC
Contributor
Contributor

@_gile Thanks for the reply.
But this did not solve the issue. 
It seems that AutoCAD 2025 .Net API does not support WPF Windows as Model Dialogues/Windows. It only supports winforms. Mostly, we use WPF windows with MVVM approach. So it is nightmare to convert all WPF UIs to Winform windows. 

If anyone has tried it ? 

 

0 Likes
Message 24 of 70

_gile
Consultant
Consultant

@imranGJ2WC wrote:

@_gile Thanks for the reply.
But this did not solve the issue. 
It seems that AutoCAD 2025 .Net API does not support WPF Windows as Model Dialogues/Windows. It only supports winforms. Mostly, we use WPF windows with MVVM approach. So it is nightmare to convert all WPF UIs to Winform windows. 

If anyone has tried it ? 

 


I did try it, and have no problem migrating WPF / MVVM dialogs or palettes to AutoCAD 2025 / .NET 8.0.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 25 of 70

Jeff_M
Consultant
Consultant

My WPF windows and usercontrols all work fine in .NET8, both Modal and Modeless.

 

What is the exception you get? Showing some code that fails may help.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 26 of 70

imranGJ2WC
Contributor
Contributor

@Jeff_M @_gile 

var dlg = new MyView();

 

MyView() is a WPF Window. When program enters in the constructor and InitializeComponent() is called, it raises the following exception. 

 

 

imranGJ2WC_0-1712580180521.png


Thanks in advance.

0 Likes
Message 27 of 70

_gile
Consultant
Consultant

I've never seen such code before. Do you use some third-party application?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 28 of 70

Jeff_M
Consultant
Consultant

@_gile that is the decompiled accoremgd.dll code. 

@imranGJ2WC Can you post the actual .xaml & .xaml.cs files? Along with the code that calls the loading of the window?

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 29 of 70

imranGJ2WC
Contributor
Contributor

@Jeff_M 

 

The code is quite simple. Attached ZIP file contains two projects .. One is .Net Framework 4.8 and other is .Net Core (Migrated according to the document shared by @_gile ).

The Core Project contains a WPF Window. The project compiles successfully but the WPF window does not load and AutoCAD crashes.

0 Likes
Message 30 of 70

_gile
Consultant
Consultant

It looks like you did not replace the AutoCAD libraries (Autodesk_ObjectARX_2019_Win_64_and_32_Bit) in the upgraded project.

You have to download ObjectARX 2025 and reference the libraries from there.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 31 of 70

norman.yuan
Mentor
Mentor

It is obvious: your updated project has references to OLD(!) AutoCAD .NET managed assemblies: they HAS TO BE AutoCAD 2025's assemblies.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 32 of 70

imranGJ2WC
Contributor
Contributor

@norman.yuan @_gile @Jeff_M 

 

After replacing the Autocad references to 2025 SDK, still an exception occurs.

imranGJ2WC_0-1712602362977.png

 

 

0 Likes
Message 33 of 70

norman.yuan
Mentor
Mentor

Well, that is a trick issue: you need to clear the "Assembly version" field in the Project properties -> Package tab, where somehow it has "24.4.8.4" in it (or click the "gear box" icon to clear/reset it). 

 

BTW, I would prefer  not to do "Upgrate" the project from .NET framework to .NET 8, after trying the upgrade process. I'd rather create a empty .NET project/solution, add necessary references/nuget packages, and then copy the CS files to be included to the project.

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 34 of 70

kerry_w_brown
Advisor
Advisor

@norman.yuan wrote:

 

BTW, I would prefer  not to do "Upgrate" the project from .NET framework to .NET 8, after trying the upgrade process. I'd rather create a empty .NET project/solution, add necessary references/nuget packages, and then copy the CS files to be included to the project.

 

 That is my preference too Norman.

 It's also my preference not to attempt sharing code between framework and net builds.

 

Regards,

 

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 35 of 70

imranGJ2WC
Contributor
Contributor

@norman.yuan 
Yes. Sir. That was the issue. I just reset the assembly version and everything is working like a charm. You made my day. 

We can not add a new WPF Window when working in a class library project (.Net 8.0) .. For this, I will always need to create/design it first in .Net Framework Project and add it as Existing File in .Net 8.0 project. 

0 Likes
Message 36 of 70

_gile
Consultant
Consultant

@imranGJ2WC wrote:

We can not add a new WPF Window when working in a class library project (.Net 8.0) .. For this, I will always need to create/design it first in .Net Framework Project and add it as Existing File in .Net 8.0 project. 


For sure you can. Starting with this template (AutoCAD R25 Plugin Template), I just added a <UseWPF>true</UseWPF> node to the first PropertyGroup one, compile and Add > New item...

_gile_0-1712661304183.png

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 37 of 70

imranGJ2WC
Contributor
Contributor

@_gile Thanks. That's really a great Template.

After fixing the Assembly Version issue as suggested by @norman.yuan, WPF Window can be added. 


0 Likes
Message 38 of 70

gleeuwdrent
Advocate
Advocate

My plugins are used in multiple versions of AutoCAD and verticals. Am I correct that after migration to .NET 8.0 we cannot have a single Visual Studio solution with all code, and built it on the .NET Framework and .NET 8.0 target? So to be compatible with 2024 and prior and 2025, I need to maintain two solutions and when I want to change/update code, change both solutions? Or is there a way to have a single source of code and use it both in 2025 and 2024/prior?

0 Likes
Message 39 of 70

_gile
Consultant
Consultant

@gleeuwdrent wrote:

My plugins are used in multiple versions of AutoCAD and verticals. Am I correct that after migration to .NET 8.0 we cannot have a single Visual Studio solution with all code, and built it on the .NET Framework and .NET 8.0 target? So to be compatible with 2024 and prior and 2025, I need to maintain two solutions and when I want to change/update code, change both solutions? Or is there a way to have a single source of code and use it both in 2025 and 2024/prior?


You can try share the same code for boths projects (in the same solution) by "linking" the code files from the original project (.NET Framework) to the new one (.NET Core).

This can be done with the  Migration Assistant by choosing "Side-by-side incremental project upgrade" or by adding a new .NET 8 project to the solution and adding the code files from the original one using Add > Existing Item and Add as link option.

In both cases, you may have some errors with parts of code in the new project which can be solved by using conditionnal compilation.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 40 of 70

imranGJ2WC
Contributor
Contributor

@gleeuwdrent 
You can maintain two projects in one solution.  For this, you must import the source files in  .Net Core project as a Link from .net Framework project. In case if there is different code for both projects, you can use Conditional Compilation Symbols ( see https://forums.autodesk.com/t5/net/developing-plugin-for-autocad-and-bricscad/td-p/10627700 and https://alexeispirit.blogspot.com/2012/06/multi-cad-coding.html). 

This will enable you to maintain the common code between both projects. 

0 Likes