Upgrading .NET Framework Add-In for Inventor 2026

Upgrading .NET Framework Add-In for Inventor 2026

ppauleSHGR6
Enthusiast Enthusiast
310 Views
4 Replies
Message 1 of 5

Upgrading .NET Framework Add-In for Inventor 2026

ppauleSHGR6
Enthusiast
Enthusiast

Hi everyone,

 

I've just upgraded my C# Inventor Add-In, which was initially developed for Inventor 2023 for .NET Framework, to .NET 8.0 and I am facing a strange behaviour of Inventor 2026 when the Add-In was loaded.

 

The issue is, that Inventor 2026 fails to open any file as soon as the Add-In was loaded before.

When opening a file, a empty windows appears in the left top corner of the application window:

 

ppauleSHGR6_0-1751988292344.png

 

When I unload/uninstall my Add-In, restart Inventor 2026, open the same file again, everything works.

When debugging in VS22 there are no exceptions thrown and I can't find any suspicious things. The code is executed without problems.

 

I don't know how to continue from this point and how to find the cause for this issue, the only thing I know is, that it is somehow related to my Add-In.

 

Thanks for any assistance, very much appreciated!

0 Likes
311 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor

could you please share some more details about the addin and what it is doing?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

ppauleSHGR6
Enthusiast
Enthusiast

Of course!

 

In general the Add-In opens a WPF dialog when saving a file, e.g. an IPT or IAM file and writes back into custom iProperties.

I'm attaching event handlers to the following events:

  • ApplicationEvents.OnActivateDocument
  • ApplicationEvents.OnSaveDocument

 

I already tried to comment these lines so only a config file gets read in the "Activate" method of the Add-In - but no success.

Plus in debug all code in the "Activate" method is executed without exceptions.


Here's the code of the "Activate" method:

public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
    try
    {
        AppSettings.Log.Info($"Loading AddIn... (Assembly={this.GetType().Assembly})");

        // Read reg keys
        // >>
        AppSettings.ServerPath = RegHandler.GetConfigPathFromReg();
        if (string.IsNullOrWhiteSpace(AppSettings.ServerPath))
            throw new Exception(@"Add-In could not be loaded. ServerPath is missing in Windows Registry");

        AppSettings.Log.Info($"ServerPath={AppSettings.ServerPath}");

        AppSettings.AssemblyFolder = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        AppSettings.Log.Info($"AssemblyFolder={AppSettings.AssemblyFolder}");
        AppSettings.Log.Info($"LayoutFolder={AppSettings.LayoutDir}");

        AppSettings.ConfigFileName = System.IO.Path.Combine(AppSettings.ServerPath, AppSettings.ConfigFile);
        AppSettings.DbConfigFileName = System.IO.Path.Combine(AppSettings.ServerPath, AppSettings.DbConfigFile);
        AppSettings.UserConfigFileName = System.IO.Path.Combine(AppSettings.ServerPath, AppSettings.UserConfigFile);

        AppSettings.Log.Info($"ConfigFileName={AppSettings.ConfigFileName}");
        AppSettings.Log.Info($"DbConfigFileName={AppSettings.DbConfigFileName}");
        AppSettings.Log.Info($"UserConfigFileName={AppSettings.UserConfigFileName}");

        if (!Directory.Exists(AppSettings.LayoutDir))
            Directory.CreateDirectory(AppSettings.LayoutDir);

        if (!System.IO.File.Exists(AppSettings.ConfigFileName))
            throw new Exception($"File not found: {AppSettings.ConfigFileName}");

        if (!System.IO.File.Exists(AppSettings.DbConfigFileName))
            throw new Exception($"File not found: {AppSettings.DbConfigFileName}");

        if (!System.IO.File.Exists(AppSettings.UserConfigFileName))
            throw new Exception($"File not found: {AppSettings.UserConfigFileName}");
        // <<

        // Read config files
        // >>
        PropertyDialog.LoadConfig(AppSettings.ConfigFileName);
        PropertyDialog.LoadDbConfig(AppSettings.DbConfigFileName);
        PropertyDialog.GetAllowedUsers();
        // <<

        m_inventorApplication = addInSiteObject.Application;
        m_inventorApplication.ApplicationEvents.OnActivateDocument += ApplicationEvents_OnActivateDocument;
        m_inventorApplication.ApplicationEvents.OnSaveDocument += OnSaving;
		
        AppSettings.Log.Debug($"Event handlers attached");

        AppSettings.Log.Info("AddIn activated");
    }
    catch (Exception ex)
    {
        AppSettings.Log.Error(ex.Message);
        if (ex.InnerException != null)
            AppSettings.Log.Error(ex.InnerException.Message);
    }
}

 

This is a snippet of the VS project file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-windows</TargetFramework>
    <ProjectType>Local</ProjectType>
    <ApplicationIcon>favicon.ico</ApplicationIcon>
    <AssemblyKeyContainerName>
    </AssemblyKeyContainerName>
    <AssemblyOriginatorKeyFile>addinname.pfx</AssemblyOriginatorKeyFile>
    <DefaultClientScript>JScript</DefaultClientScript>
    <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
    <DefaultTargetSchema>IE50</DefaultTargetSchema>
    <DelaySign>false</DelaySign>
    <OutputType>Library</OutputType>
    <RootNamespace>InvAddIn</RootNamespace>
    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
    <StartupObject>
    </StartupObject>
    <UseWPF>true</UseWPF>
    <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
    <Configurations>Debug_23;Debug_24;Debug_26;Debug;Release_23;Release</Configurations>
    <AssemblyName>addinname</AssemblyName>
    <SignAssembly>true</SignAssembly>
  </PropertyGroup>
  <!-- ... -->
</Project>

 

These are the references I use for the Add-In:

ppauleSHGR6_0-1752067279357.png

 

 

I don't understand why there is popping up an empty dialog when the Add-In only is loaded and I try to open a file even if I don't attach the event handlers.

Plus the "" event handler doesn't do anything regarding dialogs:

private void ApplicationEvents_OnActivateDocument(_Document DocumentObject, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
    HandlingCode = HandlingCodeEnum.kEventNotHandled;

    if (BeforeOrAfter == EventTimingEnum.kAfter)
    {
        AppSettings.Log.Info($"ApplicationEvents_OnActivateDocument() DisplayName={DocumentObject.DisplayName}, FileName={DocumentObject.FullFileName}");

        m_openedDoc = DocumentObject;
        Savecounter = 0; // reset save counter

        HandlingCode = HandlingCodeEnum.kEventHandled;
    }
}

 

Any help is much appreciated.

 

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor

When i went from 2023 to 2025 (.Net core) I noticed that Inventor is reacting differently to events. I can't say what is different, but I would have a look at the line

HandlingCode = HandlingCodeEnum.kEventHandled;

 in your "ApplicationEvents_OnActivateDocument" function. Try commenting it out as a test. 

 

If that does not work, you could try commenting out the line:

m_inventorApplication.ApplicationEvents.OnActivateDocument += ApplicationEvents_OnActivateDocument;

or 

m_inventorApplication.ApplicationEvents.OnSaveDocument += OnSaving;

in your "Activate(..)" function. Just as a test to see where the problem is coming from.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 5

ppauleSHGR6
Enthusiast
Enthusiast

Thank you for your reply, unfortunately not attaching the event handlers does not lead to success.

That was indeed one of the first things I tried, as I mentioned in my initial post (... I already tried to comment these lines so only a config file gets read in the "Activate" method of the Add-In - but no success.)

 

I had the same assumption as this only happens when opening a file.

 

My next approach would probably be to create a new project and transfer the logic of the existing add-in piece by piece into the new project.

I didn't come up with any new findings yet.

 

Thanks for any advice.

0 Likes