- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm pretty sure this is a bug in AutoCAD 2025. Not sure the same problem was there in AutoCAD 2024 and below though.
Here's my plugin csproject in SDK style:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<!-- <ImplicitUsings>enable</ImplicitUsings> -->
<!-- <Nullable>enable</Nullable> -->
<UseWPF>true</UseWPF>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<TargetFramework>net8.0-windows</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<EnableDefaultItems>true</EnableDefaultItems>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoCAD.NET"
Version="25.0.1"/>
</ItemGroup>
</Project>
And here's the content of the only cs file in the folder
using System.Windows;
using Autodesk.AutoCAD.Runtime;
using DummDLL;
[assembly: ExtensionApplication(typeof(HookEntry))]
[assembly: CommandClass(typeof(HookEntry))]
namespace DummDLL
{
public class HookEntry : IExtensionApplication
{
public HookEntry()
{
MessageBox.Show($"Constructor entered,{this.GetHashCode()}");
}
public void Initialize()
{
MessageBox.Show($"Initialize method entered,{this.GetHashCode()}");
}
public void Terminate()
{
}
[CommandMethod(nameof(RunCommand2))]
public void RunCommand2()
{
MessageBox.Show($"{nameof(RunCommand2)},{this.GetHashCode()}");
}
[CommandMethod(nameof(RunCommand))]
public void RunCommand()
{
MessageBox.Show($"{nameof(RunCommand)},{this.GetHashCode()}");
}
}
}
Now try to netload the DLL. You will notice that the calling sequence for the method is as thus:
- Constructor
- Initialize
Which is correct.
But now, try to call a command, such as RunCommand, the calling sequence is
- Constructor ( again! ). Which indicates that a different instance of IExtensionApplication is being called. This is a bug, I don't expect you to initialize a new plugin
- RunCommand
And if you call another command, whether RunCommand and RunCommand2, then only now, only that command will be called.
That's the problem. AutoCAD calls 2 instances of HookEntry (IExtensionApplication ), this is already a bug. And on the second instance where it really matters, the Initialize method isn't called at all. Such a scrambling of all the calling sequences will only break our plugin, as we count on that our HookEntry is called only once, and the Initialize method is being called.
Ngu Soon Hui
##########
I'm the Benevolent Dictator for Life for MiTS Software. Read more here
I also setup Civil WHIZ in order to share what I learnt about Civil 3D
Solved! Go to Solution.