Exception thrown: 'System.ArgumentException' in mscorlib.dll

  • Thread starter Thread starter NachoShaw
  • Start date Start date
N

NachoShaw

Guest
Hey

I would like to understand & manage this error better. I am working with Autodesk Inventor and with some of the API functions, there is a need to cause an error in order process. for example; adding properties or activating a project.

Properties. its recommended to try are write to it first if it exists and if it doesnt exist, catch the error and add the property then write to it.

Project. again, try and activate it first and if it doesnt exist, create it then activate it.

Private Sub SetActiveProject()
'check for open files and bail if any exist
Try
'try to activate the project based on the root folder & CompName
Dim ProjPath As String = ProjectsRootFolder & "\" & CompName & "\" & CompName & ".ipj"

oProject = oDesignProjectMgr.DesignProjects.ItemByName(ProjPath)
oProject.Activate()
UpdateProcessList("Activating existing Project - " & oProject.Name, True, True)
Catch ex As Exception
'create the project if it doesnt exist
oProject = oDesignProjectMgr.DesignProjects.Add(MultiUserModeEnum.kSingleUserMode,
CompName,
ProjectsRootFolder & "\" & CompName)
oProject.Activate()
End Try
End Sub

There are also other API functions that require this behaviour. In my immediate window, i get this error

Exception thrown: 'System.ArgumentException' in mscorlib.dll

i would prefer to be able to handle this properly so that instead of this error, i get a meaningful message related to the specific error caught at the time. For example: iProperty x doesnt exist, creating new which is then something i can add to a log. At the same time, i would like to remove the Exception thrown error.

I can write a log message in the Catch but im not sure thats enough to handle it properly. Can the Exception thrown message be suppressed and replaced with a custom message? I am add / updating up to 5000 properties in a model set so 1000's of Exception thrown errors doesnt really explain anything to me..


Thanks



Im a self taught VB.Net guy who writes code for Autodesk Inventor. I may not know the terminology but i try so please be patient. Im not a kid so please dont treat me like one :)

Continue reading...
 
Back
Top