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

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

_gile
Consultant Consultant
27,039 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,040 Views
69 Replies
Replies (69)
Message 61 of 70

sanger779DZ
Enthusiast
Enthusiast

Our .NET 4.7 application depended on System.Data.SqlServer. Since System.Data.SqlServer is not supported under .NET 8.0 we needed to change this dependency to Microsoft.Data.SqlServer which is delivered as a NuGet package.

 

The build output for the project does not automatically include the DLL files of NuGet packages so when we try to NETLOAD the application, AutoCAD can't find all of the required runtime files.

 

Is AutoCAD capable of automatically downloading dependent packages when loading an addon?

 

As a workaround I set CopyLocalLockFileAssemblies to true to the csproj file however this causes ALL dependent DLLs to be copied to the build folder even if they are already accessible in the DotNET Core 8.0 library resulting in a massive output folder.

 

Message 62 of 70

a.kouchakzadeh
Advocate
Advocate

first of all thanks to both @_gile and @Jeff_M for providing this document.
I'm facing some weird behaviors after I've upgraded my .Net 4.8 projects to .Net 8.0
Im using the Autoloader mechanism which contains a custom ribbon. however I've noticed some times when I run AutoCAD 2025, it crashes as soon as it loads. Im assuming this happens when AutoCAD is reading my xml files and is trying to load my dlls.
I think I have mistakenly not set coppy local of the ac dlls to "false". can this be the reason of getting those crashes. if this is the reason, why does it some times crash, some times not?

if not, what else should I have to look for? my autoloader is working fine with previous versions of AutoCAD.

0 Likes
Message 63 of 70

_gile
Consultant
Consultant

@a.kouchakzadeh Does this topic help?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 64 of 70

a.kouchakzadeh
Advocate
Advocate

I'll change my IExtensionApplicaiton and put it in a try catch however Im not sure if this would fix the problem since the machine Im working with has both 2024 and 2025. my bundle file is working fine with the 2024 version. in the dll that I use IExtensionApplication, Im not doing heavy calculation. its just a simple license checking. Im not loading my ribbon with a custom command. its just the CUI file which the xml files loads it.

also the other question is, how should I update my codes when I make any change or fix a bug? do I have to manually preform this changes in the 2025 versions or do the upgrading every time I make a change?


0 Likes
Message 65 of 70

mszanto
Enthusiast
Enthusiast

There is a known issue with transient objects crashing 2025 that didn't occur in 2024, but that doesn't sound like the issue you're experiencing. 
See Norman Yuan's answer and my simplified solution for that issue.

 

You'll need to include the following line in your .csproj file, otherwise your supporting assemblies like nuget references will not be copied to the output folder 

 <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

 

You should always set 'Copy Local' to No for the AutoCAD assemblies. There is no need to copy them to the output folder because they are already loaded when AutoCAD loads your plugin, and it just adds extra assemblies to your plugin that are unnecessary.

 

I'm guessing that an exception is occurring when AutoCAD loads your plugin, and you are not being notified of the exception by AutoCAD. Click here to read my post on this topic.

 

 

0 Likes
Message 66 of 70

a.kouchakzadeh
Advocate
Advocate

I noticed not setting copy local to false (in .NET 4.8) or to No (in .NET 8) some times does throw an exception as soon as AutoCAD starts. but that was now our case since we do set it to False/No. We recently installed AutoCAD 2025 and didn't use that much. I noticed the issue was with the AtuoCAD itself. 

we upgraded to 25.1.2 and the Issue is gone. but im still having alot of trouble with upgrading the projects using the upgrade extension. some times it gets stuck on finalize project dependencies.

 

0 Likes
Message 67 of 70

_gile
Consultant
Consultant

@a.kouchakzadeh  a écrit :

but im still having alot of trouble with upgrading the projects using the upgrade extension. some times it gets stuck on finalize project dependencies.


An alternative to the upgrade extension could be adding a new project targeting .NET 8.0 in the same solution (either from scratch or using some template). Then we can use "Add existing element" to add the files of the NET Framework project into the the new NET 8.0 one. Doing so, if we choose "Add as link", the file are just linked instead of beein copied which allow to maintain a single code for both project but prevents to use NET 8.0 features.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 68 of 70

a.kouchakzadeh
Advocate
Advocate

you mean I can't make use of Nullable types?

0 Likes
Message 69 of 70

_gile
Consultant
Consultant

@a.kouchakzadeh  a écrit :

you mean I can't make use of Nullable types?


Exactly. The nullable reference is a NET 8.0 feature which is not availbale with NET Framework.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 70 of 70

gpq
Enthusiast
Enthusiast

Hi Gilles,

after have reading your instruction I have make the upgrade to net8.0, but I have this error whe compile:

 

The resource file 'C:\svilupponet-VS2022\VB-Sviluppo\ExtruLib\objproject.assets.json' does not contain a target for 'net8.0-windows'. Ensure that the restore has been executed and that 'net8.0-windows' has been included in the project's TargetFramework elements.

 

Do you have an idea about this problem?

I use Visualstudio community 2022.

Thanks in advance.

Ciao!

GPQ

 

here file vbproj with your suggested modification in bold

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ProjectType>Local</ProjectType>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>HmTool</AssemblyName>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyMode>None</AssemblyOriginatorKeyMode>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>
</RootNamespace>
<StartupObject>HmDotNet.%28Nessuno%29</StartupObject>
<MyType>Windows</MyType>
<PublishUrl>http://localhost/HmTool/</PublishUrl>
<Install>true</Install>
<InstallFrom>Web</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>true</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ProjectGuid>{8D0A8E10-3ACA-4520-96A2-CC9843D14846}</ProjectGuid>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DocumentationFile>
</DocumentationFile>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>Win32 = True</DefineConstants>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<NoWarn>42016,42017,42018,42019,42032,42353,42354,42355</NoWarn>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DocumentationFile>
</DocumentationFile>
<BaseAddress>285212672</BaseAddress>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>
</DefineConstants>
<DefineDebug>false</DefineDebug>
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
<NoWarn>42016,42017,42018,42019,42032,42353,42354,42355</NoWarn>
<DebugType>none</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Update="System">
<Name>System</Name>
</Reference>
<Reference Include="accoremgd">
<HintPath>..\..\..\Program Files\Autodesk\AutoCAD 2025\accoremgd.dll</HintPath>
</Reference>
<Reference Include="acdbmgd">
<HintPath>..\..\..\Program Files\Autodesk\AutoCAD 2025\acdbmgd.dll</HintPath>
</Reference>
<Reference Include="acmgd">
<HintPath>..\..\..\Program Files\Autodesk\AutoCAD 2025\acmgd.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Import Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Folder Include="My Project\" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
</Project>

 

 

 

 

 

0 Likes