Upgrading Plugin to .Net 8.0

Upgrading Plugin to .Net 8.0

My_Civil_3D
Advocate Advocate
1,251 Views
11 Replies
Message 1 of 12

Upgrading Plugin to .Net 8.0

My_Civil_3D
Advocate
Advocate

Hi All

I have Followed a guide i found here to Upgrade my Plugin to Autocad 2025. I am having issues with Winforms.
Normally when starting a project (.class Library) you can add winforms to it. After Upgrading My Project and Even by Starting a New Project i dont see the Option to add Winforms anymore? am i missing something here?

another question is do i have to upgrade to .Net 8.0?

Civil 3D Certified Professional
0 Likes
1,252 Views
11 Replies
Replies (11)
Message 2 of 12

_gile
Consultant
Consultant

The first "PropertyGroup" element of your project SDK have to contain this element:

<UseWindowsForms>true</UseWindowsForms>

So that your classes can use System.Windows.Forms and the classes should be decored with the SupportedOSPlatform attribute:

[SupportedOSPlatform("windows")]

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 12

My_Civil_3D
Advocate
Advocate

I Have Added your Line and i Now Get this Error:

i am unsure of how to do this:

[SupportedOSPlatform("windows")]



My_Civil_3D_0-1723113116789.png

 

 

 

 

Civil 3D Certified Professional
0 Likes
Message 4 of 12

_gile
Consultant
Consultant

Did you add:

<UseWindowsForms>true</UseWindowsForms>

to the first PropertyGroup element of your project SDK? (double click on the project in the Solution Explorer to open it).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 12

ActivistInvestor
Mentor
Mentor

I upgraded a WinForms project recently, and here is what I did to include WinForms support, in addition to adding the required assemblies:

 

 

 <PropertyGroup>
   <TargetFramework>net8.0-windows</TargetFramework>
   <ImplicitUsings>disable</ImplicitUsings>
   <Nullable>disable</Nullable>
   <UseWindowsForms>true</UseWindowsForms>
 </PropertyGroup>

 

 

I haven't used the SupportedOSPlatform attribute anywhere in the project.

0 Likes
Message 6 of 12

ActivistInvestor
Mentor
Mentor

See my (misdirected) reply to @_gile. I haven't needed to use the SupportedOSPlatform attribute in my project, but I did disable the analyzers that warn about platform-dependent code.

0 Likes
Message 7 of 12

My_Civil_3D
Advocate
Advocate

i manged to get it to work by manually adidng :

 

"<UseWindowsForms>true</UseWindowsForms>"

 

another issue i am facing is with Mysql. i am getting an error saying that its not supported on this platform. first i had to change to Microsoft.dta.SqlClient but when i build my plugin the Microsoft.dta.SqlClient .dll isnt buidlign with the rest of the plugin files. Where previously before the upgrade to dotnet 8.0 i had no issues. am i missing something here?

Civil 3D Certified Professional
0 Likes
Message 8 of 12

_gile
Consultant
Consultant

@My_Civil_3D  a écrit :

i manged to get it to work by manually adidng :

 

"<UseWindowsForms>true</UseWindowsForms>"


This is what @ActivistInvestor and I have been advocating since the start of this discussion.

 


@My_Civil_3D  a écrit :

another issue i am facing is with Mysql. i am getting an error saying that its not supported on this platform. first i had to change to Microsoft.dta.SqlClient but when i build my plugin the Microsoft.dta.SqlClient .dll isnt buidlign with the rest of the plugin files. Where previously before the upgrade to dotnet 8.0 i had no issues. am i missing something here?


You can see this topic.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 9 of 12

My_Civil_3D
Advocate
Advocate

Seems Like there is Still an Issue, i can see the Winforms under the Add window but when clicking on it, it doesnt add a new form

Civil 3D Certified Professional
0 Likes
Message 10 of 12

My_Civil_3D
Advocate
Advocate

at this point i want to pull out my hair. why cant there just be a .Net 8.0 Template when you create a new project why do you have to always upgrade the project first? i only see .net 4.8 on my target projects i always have to upgrade the project why is that? 

Civil 3D Certified Professional
0 Likes
Message 11 of 12

_gile
Consultant
Consultant

Hi,

You can find an AutoCAD Project Template for AutoCAD 2025 (AutoCAD R25 Csharp Project Template) on this page. You'll have to edit the template files as explained in the "README" and, to reference Windows Forms, add: <UseWindowsForms>true</UseWindowsForms> to the first PropertyGroup node of the .csproj file.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 12 of 12

My_Civil_3D
Advocate
Advocate
thank you sir
Civil 3D Certified Professional
0 Likes