Next year the company I work for will migrate to Inventor 2025. Although this might seem early, I want to start updating my add-ins now. However, there are some challenges. Until we migrate I need to support Inventor 2023. This means I need to support Inventor 2023 with .Net framework 4.7.2 and Inventor 2025 with .Net core 8.0. Now I have discovered that it's possible to target multiple .NET versions in a single project. This allows you to compile and debug for both .NET Framework and .NET Core.

If you haven’t started migrating your add-ins to be compatible with Inventor 2025 and .NET Core 8.0, then that is the first thing you need to do.

Once your migration is done, open the .csproj file of your add-in project. You’ll find a line that looks like this:

<TargetFramework>net8.0-windows</TargetFramework>

Change it to this:

<TargetFrameworks>net8.0-windows;net48</TargetFrameworks>

Note that the XML element is now plural (<TargetFrameworks>), so be sure to add an "s" to both the opening and closing tags.

Configuring References for Different Frameworks

Visual Studio will attempt to compile your add-in for both .NET 4.8 and .NET Core 8.0. However, each framework version requires different references. You can specify these references using conditions within the ItemGroup element in your .csproj file.

Here’s how you can configure the references:

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-windows'">
    <Reference Include="Autodesk.Inventor.Interop">
        <HintPath>C:\Program Files\Autodesk\Inventor 2025\Bin\Autodesk.Inventor.Interop.dll</HintPath>
        <Private>True</Private>
        <EmbedInteropTypes>False</EmbedInteropTypes>
    </Reference>
    <Reference Include="stdole">
        <HintPath>C:\Program Files\Autodesk\Inventor 2025\Bin\stdole.dll</HintPath>
    </Reference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
    <Reference Include="Autodesk.Inventor.Interop"&gt
        <HintPath>C:\Program Files\Autodesk\Inventor 2024\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll</HintPath>
        <Private>True</Private>
        <EmbedInteropTypes>False</EmbedInteropTypes>
    </Reference>
    <Reference Include="stdole">
        <HintPath>C:\Program Files\Autodesk\Inventor 2024\Bin\stdole.dll</HintPath>
    </Reference>
</ItemGroup>

You can also add other DLL references that need to be loaded. This is useful if your add-in relies on additional libraries like iLogic.

Handling Code Differences Between Frameworks

If you have code that only works for one version of .NET, you can use conditional compilation:

#if NETFRAMEWORK
    System.Windows.MessageBox.Show("This message will only be shown if the target framework is .Net Framework");
#else
    System.Windows.MessageBox.Show("This message will only be shown if the target framework is .Net Core 8.0");
#endif

Managing Output Files

When it comes to output files, you have a few options:

  1. Set the output directory to where Inventor expects the files.
  2. Copy the files(automatically) to the expected location.
  3. Create a custom .addin file for debugging purposes.

Option 1 isn’t ideal because the output directory can become cluttered with unnecessary files. Also, when targeting multiple frameworks, Visual Studio compiles the solution twice, which will lead to files being overwritten in the output folder.

Option 2, which is Autodesk’s recommended approach, usually works well. However, it still involves the issue of files being copied twice and will overwrite each other.

Option 3, though not typically recommended, can be useful in this scenario. (Normally it would be best to match your development environment as closely as possible to the production environment.) When you create 2 separate addin files. Then you can start Inventor using the files from the specific target framework that you need.

Creating Separate .addin Files

To implement option 3, you'll need to craft two separate ".addin" files. Each file should be tailored to correspond with a specific target folder in your solution folder. The addin file for Inventor 2024 should look something like this:

<Addin Type="Standard">
	<ClassId>{[GUID here]}</ClassId>
	<ClientId>{[GUID here]}</ClientId>
	<DisplayName>[Name]</DisplayName>
	<Description>[Description]</Description>
	<Assembly>c:/[Path to your solution]/bin/debug/net48/[File name of the dll]</Assembly>	
	<SupportedSoftwareVersionGreaterThan>20..</SupportedSoftwareVersionGreaterThan>
</Addin>

(Notice that the assembly node contains a full path and not a relative path as you usually would use. Also, notice that the path is to the target .Net 4.8 folder.)

The addin file for Inventor 2025 should look like this:

<Addin Type="Standard">
	<ClassId>{[GUID here]}</ClassId>
	<ClientId>{[GUID here]}</ClientId>
	<DisplayName>[Name]</DisplayName>
	<Description>[Description]</Description>
	<Assembly>c:/[Path to your solution]/bin/debug/net8.0-windows/[File name of the dll]</Assembly>	
	<SupportedSoftwareVersionGreaterThan>20..</SupportedSoftwareVersionGreaterThan>
</Addin>

Placing the .addin Files

You should place your .addin files in an Inventor version-specific folder. That means in one of these folders:

  • For inventor versions =< 2024
    • %ALLUSERSPROFILE%\Autodesk\Inventor 20xx\Addins\
    • %APPDATA%\Autodesk\Inventor 20xx\Addins\
  • For Inventor versions >= 2025
    • %PROGRAMFILES%\Autodesk\Inventor 20xx\Bin\Addins\
    • %APPDATA%\Autodesk\Inventor 20xx\Addins\

Conclusion

Supporting both Inventor 2023 and Inventor 2025 might seem challenging, but with careful planning and the right approach, it can be done smoothly. By targeting multiple .NET versions within a single project, you ensure that your add-ins remain compatible with different Inventor versions.

 

 

 

 

Skills:

Autodesk Inventor, Vault, Git, C#, vb, .net, php HTML, css, js

Education:

University computer science.
HBO Mechanical engineer.
MBO Fine mechanics.

Experience:

Programmer and Mechanical engineer at Kelvion
(2016 - 20..)

Mechanical engineer at Strukton
(2009 - 2016)

Mechanical engineer at RDG-engineering
(2007 - 2009)

CNC Programmer at VMC
(2005 - 2007)

volunteer at Taizé
(2007)

Certifications:

Objectgeoriënteerd analyseren en ontwerpen, Objectgeoriënteerd programmeren in Java, Webapplicaties: de clientkant, Databases, Security Aware Programmer, Web Security Specialist