.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Class Library Upgrade to .NET 8.0 to use Winforms & Mysql

2 REPLIES 2
Reply
Message 1 of 3
Domzinator
213 Views, 2 Replies

Class Library Upgrade to .NET 8.0 to use Winforms & Mysql

Hi Guys

I thought i would share my solution to upgrade a Class Library Project to .Net 8.0 for Plugins for Autocad 2025. i see allot of people being confused regarding this whole topic especially when it comes down to using Microsoft.Data.SqlClient.

Create a New Class Library (.NET FrameWork).
Create your Project as Usual

My_Civil_3D_0-1724593355996.png

Right Click On your Solution in the Solutions Explorer and select "Upgrade"

My_Civil_3D_1-1724593490959.png

 

Because this is a new Project i am going to to an In-Place Project Upgrade:

My_Civil_3D_2-1724593543248.png

 

Choose .NET 8.0 (Make sure that you have installed the .net 8.0 SDK
link:  https://dotnet.microsoft.com/en-us/download/dotnet/8.0 

Once the Project is Upgraded its important that we do a few necessary steps to ensure everything is set up correct.
In my case i want to use SQL Client, Winforms.

Open The Properties op your Solution, and set the following options.
Target OS: Windows
Platform Target: x64
Nullable: Enable (Preference)
Set the Rest of Your properties as required.

Install Microsoft.Data.SqlClient (If Required). in the nuget package manager

My_Civil_3D_3-1724593899419.png


Now Add you Autocad .dll reference files. Just a small note that this can also be added via the nuget package manger when searching for Autocad:

My_Civil_3D_4-1724594058144.png


This is What my Project file looks Like now after adding my .dll files:

 

 

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <OutputType>Library</OutputType>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <AssemblyTitle>Test_Class</AssemblyTitle>
    <Company>SCCM-SUN-ZA</Company>
    <Product>Test_Class</Product>
    <Copyright>Copyright © SCCM-SUN-ZA 2024</Copyright>
    <AssemblyVersion>1.0.0.0</AssemblyVersion>
    <FileVersion>1.0.0.0</FileVersion>
    <PlatformTarget>x64</PlatformTarget>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Identity" Version="1.12.0" />
    <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
    <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
    <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="accoremgd">
      <HintPath>..\..\..\..\..\Program Files\Autodesk\AutoCAD 2025\accoremgd.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Acdbmgd">
      <HintPath>..\..\..\..\..\Program Files\Autodesk\AutoCAD 2025\acdbmgd.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Acmgd">
      <HintPath>..\..\..\..\..\Program Files\Autodesk\AutoCAD 2025\acmgd.dll</HintPath>
      <Private>False</Private>
    </Reference>
  </ItemGroup>
</Project>

 

 


Now Lets Continue....

 

There are a few manual steps to be added to ensure that you will be able to use winforms if needed and also make sure that you will be able to use the mySql Client.

This is my Project file after adding a few manual lines:

 

 

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <OutputType>Library</OutputType>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <AssemblyTitle>Test_Class</AssemblyTitle>
    <Company>SCCM-SUN-ZA</Company>
    <Product>Test1</Product>
    <Copyright>Copyright © SCCM-SUN-ZA 2024</Copyright>
    <AssemblyVersion>1.0.0.0</AssemblyVersion>
    <FileVersion>1.0.0.0</FileVersion>
	  <RuntimeIdentifier>win-x64</RuntimeIdentifier>
	  <PlatformTarget>x64</PlatformTarget>
    <Nullable>enable</Nullable>
	  <UseWindowsForms>true</UseWindowsForms>
	  <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Identity" Version="1.12.0" />
    <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
    <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
    <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="accoremgd">
      <HintPath>..\..\..\..\..\Program Files\Autodesk\AutoCAD 2025\accoremgd.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Acdbmgd">
      <HintPath>..\..\..\..\..\Program Files\Autodesk\AutoCAD 2025\acdbmgd.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="Acmgd">
      <HintPath>..\..\..\..\..\Program Files\Autodesk\AutoCAD 2025\acmgd.dll</HintPath>
      <Private>False</Private>
    </Reference>
  </ItemGroup>
</Project>

 

 


YOu will be able to spot the added lines:

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

the "<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>" is only needed to use mysql otherwise the mysql.dll files will not be generated when building your plugin.





 

 

Civil 3D Certified Professional
2 REPLIES 2
Message 2 of 3
_gile
in reply to: Domzinator


@Domzinator  a écrit :
[...]

Create a New Class Library (.NET FrameWork).
Create your Project as Usual

[...]

Right Click On your Solution in the Solutions Explorer and select "Upgrade"

[...]


Why not simply create a New Class Library (.NET or .NET Standard instead of .NET Framework)?

Or use some AutoCAD R25 Project Template?

And then, edit the project SDK (.csproj file) to suit your needs.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3
Domzinator
in reply to: _gile

There are many ways to do this, i thought i would just share some info that might be helpfull. but you are correct

Civil 3D Certified Professional

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report