“Member not found” error in C# add-in

As mentioned in other blog posts (e.g. here and here) as well, using Embed Interop Types = True with the Inventor interop assembly does not work well. 

Apart from some events not firing, you might not find all the properties either. E.g. in the case of a Parameter object, when doing this: 

var unitType = param.get_Units();

I get this error:

{"Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))"}

So just set Embed Interop Types to False:

EmbedInteoropTypes

Just for completeness’ sake (though the above solution should solve the problem), there could be another way as well to avoid this error.
You could declare a dynamic variable for the parameter (in order to use late-binding) and access the property through that:  

dynamic p = param;
var unitType = p.Units;

– Adam


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading