Hello All,
I've been poking at making a .NET 6 add-in for Inventor for a while. Most of my attempts resulted in something that wouldn't load, but finally I have something worth sharing.
https://github.com/PockyBum522/template-inventor-core-addin
WHY:
Going forward, .NET 6 is the version that is getting new features. .NET framework still exists, and I believe will get security updates, but you are limited to lower versions of the C# language when making add-ins.
Between the above, performance improvements, and many other well-documented advantages to using .NET 6, I wanted to see if it was possible to make an Add-In with a .NET 6 project that could load in Inventor.
Behold:
HOW:
To test this out, check out the github project and look at readme.md for full instructions.
Once you have built the project and copied the files per readme.md's instructions, you should be able to open a part, and click on Tools > Core Addin Show Partname and have it show the filename like in the first screenshot.
I offer absolutely no warranty on this, and I don't even know if it's useful or if there will be restrictions on what you can put into your Add-In and still have it work. I mostly just wanted to share it as I haven't seen a working .NET 6 addin on the forums, and wanted to both let AutoDesk know there is demand for it + get people playing around with it to learn more.
Tested with: Visual Studio 2022 17.1.2 and Inventor 2022 Build 287, 2022.2.2
Thanks
Thanks for the information!
.Net 5/6 support is very important, is there any official statement from Autodesk?
Inventor has not been fully tested with .NET 5 so we cannot guarantee that it will work without any issues.
After having a little poke around, it doesn't look like this is actually a .NET 5 AddIn. the addin you created seems to still be targeting .NET Framework (Version=v4.0).
Noticed this when creating a reference to a shared project in VS2019 and I received these errors:
Strange, since CoreAddIn.csproj has <TargetFramework>net5.0-windows</TargetFramework>
I'll look into it a little bit more and see if I can figure out what's going on.
Why did you put a repository on GitHub? Then we can download a ready to use project. Also, it would easier to track changes.
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.
Blog: hjalte.nl - github.com
Hi,
did you find out more in the meantime?
I'm curious to test a 'real' .NET 5 or 6 addin to try some things and maybe try refactoring existing addins to make them future proof in the foreseeable future.
https://github.com/PockyBum522/template-inventor-core-addin
I put it on GitHub. I'm about to do the checking around and updating it to .NET 6 to see what's up.
You all are correct. Somehow, even though the project was set to target .net 5.0 in the csproj, it's still showing up as Framework in Visual Studio, as you've shown, yan.gauthier.
I am starting a new project from scratch to attempt to fix this. Will post when I have results.
@Tom_Fuller @JelteDeJong @DKonzelmann @yan.gauthier
Take a look at the updated original post and github project.
It is now showing correctly in Visual Studio as shown here:
Hey,
It's actually working! after few attemps, I thought it was not possible.
When I have some times, I will try and create projects that uses libraries Inventor does to see if using .NET conflict with .NET Framework. https://modthemachine.typepad.com/my_weblog/2021/07/3rd-party-libraries-used-by-inventor.html
I might also try to convert my addin to .NET 6. I will need to convert my code from EF6 et EF Core, but the rest should be easy enough.
Thank you for your attempts. Will wait for further results.
To me, unfortunately, the minimal .NET 6 Inventor add-in (see attachment) does not load - it displays in the add-ins list but cannot load.
I also tried to get it to work through COM, by registering with regsvr32.exe and setup of proper registry entries to get it visible for Inventor (as described here in ' #Region "COM Registration" '). But this old way, used till Inventor 2011 seems to not supported anymore.
I suppose this old way might provide loading of .NET 6 add-ins even without moving Inventor itself from .NET Framework 4.8 to .NET 6, but seems this way no more supported by Autodesk.
By the way, SolidWorks can loads .NET 6 add-ins without any tricks (see attachment) - probably, usage of COM technologies allows such runtimes mixing (don't know how it's actually works).
Hi,
Please have a look at what @pockybum522 did. Your project does not use System.Runtime.InteropServices and set the AddInServer class COM Visible. Also, I believe one of the key component is the manifest file that is copied to the directory so that the dll is self registered. Otherwise, you would need to manually register said dll.
@pockybum522 can you confirm ?
Yeap. The github project brought me the missed things. And now it works!
Here is the minimal project from me (see attachment).
Thank you guys, @yan.gauthier @pockybum522
Awesome. Yes, the manifest file is important and must be named exactly like FileName.dll.manifest matching your main DLL.
Glad you got it working.
By the way, for what it's worth, I've ported over a large Add-In that does a fair number of things in Inventor that my company uses internally, and everything works great. WPF, Interop stuff, new C# features, etc.
I would be comfortable saying that this is fairly usable going forward. Since an Add-In is just exposing a COM interface to Inventor I see no reason why this should have any issues. I will report back if I run into anything that is a problem.
Hi,
I also just ported an Addin. The main issue was Inventor's events that, sometimes, get dropped. Instead of subscribing to the delagate, I reproduced the method you used in your demo and seems like it fixed the problem. All I have left to do, is to learn the differences between EF6 and EF Core.
Again, thank you for being the first one, to my knowledge, to enable .NET (not framework) with Inventor API.
Hey Guys,
I've been working with our extensive suite of tools and .NET 6.0 that integrate into Inventor and haven't run into any issues outside of the now resolved late-binding work around. Inventor.Document type doesn't work for functions that could be run on an assembly OR part; it doesn't have "componentdefinition" defined for that variable type and errors out.
There were other issues with the way some stuff was coded around MS Office APIs for Outlook/Word/Excel that had to be fixed. One issue is that you have to embed the interops for Office (only) so it makes debugging painful as you can't edit and resume. Because of how much we integrate office with Inventor I probably wouldn't upgrade to .NET 6.0 given the choice again however we did eventually get it all working again.
The .NET 6.0 migration tool worked very well for my project.
Cheers,
Can't find what you're looking for? Ask the community or share your knowledge.