Fail to continue develop Inventor Add-In with Visual Studio 2022 (revert to VS 2019?)

Fail to continue develop Inventor Add-In with Visual Studio 2022 (revert to VS 2019?)

Maxim-CADman77
Advisor Advisor
2,689 Views
21 Replies
Message 1 of 22

Fail to continue develop Inventor Add-In with Visual Studio 2022 (revert to VS 2019?)

Maxim-CADman77
Advisor
Advisor

(this thread is consequent to this)

 

Recently I've bought a new PC and decided to use most recent Visual Studio 2022 Community instead of VS 2019 Community I have on my old PC ... BUT

When I tried to compile the code of my add-in on my new PC it failed reporting error BC31424 on all mentions of "stdole.IPictureDisp" (ribbon button images).

 

I then decided to add Microsoft.VisualStudio.Interop.DLL references of the project*.

This solved compile issue but Add-In button than failed to load into Inventor's ribbon with catch-Message:
"Method not found: 'Void Inventor.ButtonDefinitionObject.set_StandardIcon(stdole.IPictureDisp)'."

 

I'm a bit puzzled. Initial project code keep compile successfully in VS 2019.

 

What I'm missing?

 

*
I've found such recommendation for Excel Add-In developers - New version requiring Microsoft.VisualStudio.Interop.dll 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
2,690 Views
21 Replies
Replies (21)
Message 2 of 22

bradeneuropeArthur
Mentor
Mentor

use an earlier Framework instead.

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 22

Maxim-CADman77
Advisor
Advisor

@bradeneuropeArthur 

... with all the respect, your advice neither sounds logical (why should I downgrade Framework on upgrading software?) nor help.


Initially my code targets Net.Framework 4.8 (which is the recommendation of most relevant article I've found - Creating an Inventor Addin )
Even so I've tried to use both 4.7.2 and 4.8.1 ... without any change/progress of course.

 

PS:
.. I even tried 3.5 but it just failed to compile with 50+ errors regarding almost everything related to Inventor (version 2022).

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 4 of 22

bradeneuropeArthur
Mentor
Mentor
My suggestion is based on and simple that I can remember (when I am right) that "stdole.IPictureDisp" is not there anymore after Framework 3.5.

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 5 of 22

Maxim-CADman77
Advisor
Advisor

@bradeneuropeArthur 
I believe this is not true (this same Net Framework 4.8 targeted code was successfully compiled with VS 2019).

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 6 of 22

Maxim-CADman77
Advisor
Advisor

Dear @JelteDeJong 

I did the clear experiment:
I've downloaded the MyILogicAddin-master.zip by 'Download' link present in your Creating-an-Inventor-Addin tutorial.
I then unpack it an open the MyILogicAddin.sln file with VS 2022 Community, run Build and got a bunch of errors and couple of warnings:

MaximAnatoljevich_0-1693497200004.png

The last two warnings are clear, expected and can be easily fixed (replace references to DLLs of Inventor 2021 with those of really installed Inventor release).
But what I'm missing regarding those six stdole-related errors?

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 7 of 22

Frederick_Law
Mentor
Mentor

I remember "stdole.IPictureDisp" but some point in time I moved away from it.

PS Didn't move away.  It's in another file: InventorButton.vb

 

I found an old project still have that.  I'll try to build it again.

Last build was IV2018, .Net 4.7.1.  Still work with IV2023.

We might be using the same "PictureDispConverter.vb".

0 Likes
Message 8 of 22

Frederick_Law
Mentor
Mentor

No problem building 4.7.1 and 4.8.1.

Do you have post build manifest?  There is no mt.exe anymore and I've deleted it.

Don't think that's your problem.

VSstdole-01.jpg

 

BTW:

https://learn.microsoft.com/en-us/dotnet/visual-basic/misc/bc31424

0 Likes
Message 9 of 22

Maxim-CADman77
Advisor
Advisor

@Frederick_Law 

My problem - I don't know the working way to create Inventor Addin with the button by means of VS 2022 .
I've already developed several more-or-less working addins:
- one with a button (by means of VS 2019 Community).
- couple button-less (by means of VS 2022 Community). 
Now I want to develop a new addin with button by means of VS 2022 Community but neither of known methods works for me nowadays 😞

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 10 of 22

Frederick_Law
Mentor
Mentor

I don't think there is any different.

The one I just build was VS2017 Community or earlier.

 

Which template are you using?

My Template attached.

0 Likes
Message 11 of 22

Maxim-CADman77
Advisor
Advisor

@Frederick_Law 
Could you, please, repeat the sequence (reproduce the errors) described in the message #6 of this thread?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 12 of 22

Frederick_Law
Mentor
Mentor

That's "iLogic" addin, not a Inventor Addin.

What kind of addin are you trying to do?

 

I have 2 working ribbon templates.  Don't really want to debug someone else template 😋

Especially when it's using code that I don't use anymore.  Not that one is better.

PS Those code are in another file: InventorButton.vb

BTW it does use the same PictureDispConverter.vb as I had.

So something wrong in the code.

 

PS: "PictureDispConverter" is wrapped in "MyButton" this is outside my knowledge.

The error you got is related to this "wrapping".

 

Oh, also it'll be difficult to convert a Solution to Template.

Been there, done that a few times.

Took a while to get one to work in VS Community 2017.

VS 2020, I think, changed everything.  Had to set it all up again.

0 Likes
Message 13 of 22

Maxim-CADman77
Advisor
Advisor
Accepted solution

Ok.
As soon as I forget about 'a better way' from that 'iLogic-Addin' Tutorial I've found, uncommented and modified a bit the code present in standard VS-Template and got some progress.


Here is how my button looks like within the Light theme:

MaximAnatoljevich_1-1693503738133.png

 

But that same icon (see attached) looks horrible within the Dark theme:

MaximAnatoljevich_2-1693503887380.png

 

I believe I should disable somehow the auto-transparancy, right?

 

PS:
I've tried to replace PNG with BMP but got the same result...

 

PPS:
Here is the project's repository - https://github.com/CadMan77/BomQtyManager

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 14 of 22

Frederick_Law
Mentor
Mentor

I think IV use different icon, unless there is way to change black arrow to white.

Look at the Extrude icon in light and dark mode.

0 Likes
Message 15 of 22

Maxim-CADman77
Advisor
Advisor

I agree this can be. But question is - how to tell IV not to cut-off (make transparent) the icon's background?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 16 of 22

Frederick_Law
Mentor
Mentor

I know BMP use "pink" as transparent.

I don't remember how PNG use to define transparent.

0 Likes
Message 17 of 22

Maxim-CADman77
Advisor
Advisor

My guessing - you mean 'Magenta' (255, 0, 255) mentioned at almost end of "Inventor Icon Design Guidelines.pdf" (it can be found at ...\SDK\DeveloperTools\Docs\Guidelines\ after SDK installation).
...but this is related to browser Icons, and mine background is white...

Please vote for Inventor-Idea Text Search within Option Names

Message 18 of 22

Frederick_Law
Mentor
Mentor

I open your icon in Paint 3D and it didn't show as transparent.

0 Likes
Message 19 of 22

Maxim-CADman77
Advisor
Advisor

Ok.
It seems like only 'Pure White' (255, 255, 255) becomes transparent.
Thus the easiest workaround is to use 'almost White' (ex. '254, 254, 254') instead ...

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 20 of 22

JelteDeJong
Mentor
Mentor

To be clear the object type "stdole.IPictureDisp" is used by the Inventor API for images. In this case for the icons of your buttons. Therefore there is no working around or moving away from them. (I would like it very much if it was possible.) To process those objects you need a reference to the stdole.dll. in the Inventor installation directory, you will find the dll and you can reference that stdole.dll. You can find it here:

C:\Program Files\Autodesk\Inventor [VERSION]\Bin\stdole.dll

The object type "stdole.IPictureDisp" is very old. In fact, it is so old that Microsoft does not support any direct conversion any more from "System.Drawing.Icon" or "System.Drawing.Bitmap" to "stdole.IPictureDisp". (Those object types are the most common at the moment.) There used to be a conversion class "VisualBasic.Compatibility.VB6.Support.IconToIPicture" but it has been deprecated. Therefore a utility class was created by "Philippe Leefsma" back in 2012. (link1 and link2)

Anyway, some of this information is in my tutorial "Adding icons to your buttons". There is also some other information that might be interesting.

The MyILogicAddin solution you found and downloaded is the result of all tutorial parts not just the first. in the complete tutorial there is information about each file and setting in the solution. 

http://www.hjalte.nl/tutorials

 

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