Using Try & Catch to solve exception I am working on a ADDIN that works on 3D drafting program. This ADDIN has historically grown and now I am doing a big rewrite.

During this rewrite I came across a issue. I have 2 (fairly similar) types of models I am trying to edit using the same code block ADDIN. They both have a property name (inside the 3D drafting progam) that does the same but the property name is different.

This difference is giving me a exception. But I am sure that there is only are two different names.

Is it acceptable to use Try and Catch like this?

' Set reference to the user defined property set
Dim oUserProperties As PropertySet =
    ReferencedDocument.PropertySets.Item("Inventor User Defined Properties")

Try
    oUserProperties.Item("Noz_Eccentric").Value = Eccentric
Catch ex As Exception
    oUserProperties.Item("Noz_Radius").Value = Eccentric
End Try


OR would it be better to rename the property when the exception is encountered? (sort of a file migration)

' Set reference to the user defined property set
Dim oUserProperties As PropertySet =
    ReferencedDocument.PropertySets.Item("Inventor User Defined Properties")

Try
    oUserProperties.Item("Noz_Eccentric").Value = Eccentric
Catch ex As Exception
    oUserProperties.Item("Noz_Radius").Name = "Noz_Eccentric"
    oUserProperties.Item("Noz_Eccentric").Value = Eccentric
End Try


Please do not comment on the o prefix used. It is common within the 3D drafting program API sample and I kinda inherited this behavior..
This question is highly specific to the Autodesk Inventor SDK.

While it's not really nice way to check if a property exists, it's documented by Autodesk 
Inventor as the way to do it, since there's not a simple "Check if a property exists" method on the property set (which is very stupid).

The sample in VBA (not VB.Net) that Autodesk Provides can be found there

The main reason being that catching an Exception can be slower than checking if a method exists. 

So in theory if you use this a lot (e.g. 1000 times in a loop), it may be theoreticaly be cleaner/faster/better, to first check which properties are defined, using the method:

PropertySet.PropertyInfo()


And check if the property exists.

That being said, Inventor may or may not use a COM+ interface which is not too fast. 

If performance is not an issue, a practical advice can be to try to set the property and otherwise add it, if it does not exist.