Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inventor .NET 6 Add-In (.NET Core followup version)

24 REPLIES 24
Reply
Message 1 of 25
pockybum522
3654 Views, 24 Replies

Inventor .NET 6 Add-In (.NET Core followup version)

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. 

 

GITHUB:

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:

pockybum522_0-1629196739715.png

 

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

Labels (7)
24 REPLIES 24
Message 2 of 25
Patrick1323
in reply to: pockybum522

Thanks for the information!
.Net 5/6 support is very important, is there any official statement from Autodesk?

Message 3 of 25
adam.nagy
in reply to: Patrick1323

Inventor has not been fully tested with .NET 5 so we cannot guarantee that it will work without any issues.



Adam Nagy
Autodesk Platform Services
Message 4 of 25
Tom_Fuller
in reply to: pockybum522

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:

ThomasfullerBZKKF_0-1633780322908.png

 

 

Message 5 of 25
pockyti
in reply to: Tom_Fuller

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.

Message 6 of 25
JelteDeJong
in reply to: pockyti

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.

EESignature


Blog: hjalte.nl - github.com

Message 7 of 25
DKonzelmann
in reply to: pockyti

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.

Message 8 of 25
pockybum522
in reply to: pockybum522

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.

Message 9 of 25
pockybum522
in reply to: JelteDeJong

That's a good idea, so I did. Updated original post

Message 10 of 25
yan.gauthier
in reply to: pockybum522

Hi, 

 

This project targets .NET Framework 4.0. It is not a .NET project. 

 

yangauthier_0-1649258588276.png

 

Message 11 of 25
pockybum522
in reply to: pockybum522

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.

Message 12 of 25
pockybum522
in reply to: pockybum522

@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:

 

pockybum522_0-1649691802454.png

 

Message 13 of 25
yan.gauthier
in reply to: pockybum522

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.

Message 14 of 25
vubaxaj
in reply to: pockybum522

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).

Message 15 of 25
yan.gauthier
in reply to: vubaxaj

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 ?

 

 

Message 16 of 25
vubaxaj
in reply to: yan.gauthier

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 

Message 17 of 25
pockybum522
in reply to: vubaxaj

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.

Message 18 of 25
pockybum522
in reply to: pockybum522

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.

Message 19 of 25
yan.gauthier
in reply to: pockybum522

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.

Message 20 of 25

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report