Upgrading Inventor Add-ins to .NET 8: Image Handling & Interop Best Practices

With Autodesk Inventor 2026 and modern development tools like Visual Studio 2022 and .NET 8, many developers are upgrading and modernizing their Inventor add-ins. This migration brings clear benefits — improved performance, future compatibility, and simplified deployment — but it also introduces new patterns for COM interop, image handling, and ribbon UI resources.

One of the most common issues developers encounter during migration is:

Inventor fails to load the add-in whenever ribbon button images are used.
(But loads perfectly when using text-only buttons.)

In this post, we’ll explore why this happens, how to fix it, and what has changed for .NET 8–based Inventor add-ins.


The Challenge: When Images Break Your Add-in

Developers migrating from older Inventor versions (using .NET Framework 4.7) have reported the following behaviour in Inventor 2026.1:

  • ✔ The add-in loads correctly when using text-only ribbon buttons
  • ✖ The add-in fails to load as soon as a custom icon is assigned

This issue did not occur in Inventor 2020–2024 but became visible after switching to:

  • Inventor 2026.1
  • .NET 8
  • The new COM interop model

The root cause?
Changes in how .NET 8 handles image → COM IPictureDisp conversion.


The Fix: Safe Image Conversion Using IPictureDisp

To reliably load images in Inventor 2026+, icons must be converted to Inventor.IPictureDisp using a safe helper that leverages a hidden AxHost wrapper.

Below is the recommended utility method for .NET 8 add-ins.


Utility Class: Image → IPictureDisp Conversion

using stdole;
using System.Drawing;
using System.Windows.Forms;

public static class ImageConverterUtil
{
    public static IPictureDisp ConvertImageToPictureDisp(Image image)
    {
        return (IPictureDisp)AxHostWrapper.GetIPictureDispFromPicture(image);
    }

    private class AxHostWrapper : AxHost
    {
        private AxHostWrapper() : base("") { }

        public static object GetIPictureDispFromPicture(Image image)
        {
            return GetIPictureDispFromPicture(image);
        }
    }
}

Usage Example — Creating a ButtonDefinition

var icon = Properties.Resources.MyCustomIcon; // .png or .ico

var largeIcon = ImageConverterUtil.ConvertImageToPictureDisp(icon);
var smallIcon = ImageConverterUtil.ConvertImageToPictureDisp(icon);

_buttonDef = invApp.CommandManager.ControlDefinitions.AddButtonDefinition(
    "MyDrawingDocButton",
    "MyCompany.DrawingDocButton",
    CommandTypesEnum.kShapeEditCmdType,
    "{YOUR-GUID-HERE}",
    "Button tooltip text",
    "Button description",
    smallIcon,
    largeIcon,
    ButtonDisplayEnum.kAlwaysDisplayText
);

✔ Once this conversion method is implemented, icons load correctly
✔ Add-ins no longer fail during startup
✔ Works reliably across Inventor 2026 and future releases


What’s New for .NET 8–Based Inventor Add-ins

Migrating from Inventor 2024 (.NET Framework) to Inventor 2026 (.NET 8) involves several important updates.


1. Use Inventor.IPictureDisp — No Need for stdole NuGet

Before (.NET Framework 4.7)Now (.NET 8)
Developers referenced stdole via NuGetNo longer necessary
Manual interop alignment requiredInventor.IPictureDisp is provided directly in Autodesk.Inventor.Interop.dll

✔ Cleaner project setup
✔ Fewer dependencies


2. Updated Interop Reference Settings

Correct reference settings for .NET 8:

Setting.NET Framework (≤ 2024).NET 8 (Inventor 2026+)
Embed Interop TypesTrueFalse
Copy LocalFalseTrue

Why the change?

  • .NET 8 uses a different COM activation model
  • Interop DLLs must be shipped alongside your add-in
  • Embedded types prevent correct COM binding

✔ Set Embed Interop Types = False
✔ Set Copy Local = True


Key Takeaways for a Smooth Migration

Here’s a consolidated checklist for developers modernizing their Inventor add-ins:

Image & Ribbon Icons

  • ✔ Use safe conversion: AxHost → IPictureDisp
  • ✔ Avoid direct .NET → COM image casting in .NET 8

Interop

  • ✔ Use Autodesk.Inventor.Interop.dll
  • Embed Interop Types = False
  • Copy Local = True

Ribbon Control Definitions

  • ✔ Always convert icons before passing them to Inventor

Conclusion

Migrating to .NET 8 and Inventor 2026+ brings many benefits — smoother deployment, improved performance, and long-term compatibility. However, add-ins using ribbon icons must update their image conversion approach to avoid loading failures.

By implementing the IPictureDisp conversion method and adjusting interop settings, developers can ensure:

  • Stable add-in loading
  • Proper icon rendering
  • Fully compatible .NET 8–based Inventor extensions

Comments

2 responses to “Upgrading Inventor Add-ins to .NET 8: Image Handling & Interop Best Practices”

  1. MacKenzie Avatar
    MacKenzie

    Is there anything here that is not applicable in Inventor 2025?

    1. Adam Nagy Avatar
      Adam Nagy

      Don’t think so. Should be the same in Inventor 2025.

Leave a Reply to MacKenzieCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading