Project Professional 2007: TimeScaleValue Results in COM Exception

The Project Professional 2007 TimeScaleValue object can result in a COM exception, or other crash, if used several times in quick succession. Reference to this method can be found at here. The error may be:AutomationException: 0x800a03ec - An unexpected error occurred with the method -- but depending where you are using the methodand which language […]

The Project Professional 2007 TimeScaleValue object can result in a COM exception, or other crash, if used several times in quick succession. Reference to this method can be found at here. The error may be:

AutomationException: 0x800a03ec - An unexpected error occurred with the method -- but depending where you are using the methodand which language you are using you will get different wording and HEX code.

Calling TimeScaleData method returns a TimeScaleValues collection containing TimeScaleValue items. When iterating through returned list in C#, VB.NET or VBA and accessing Value member of each item, a COM Exception can occur on or about the 10th returned value. This's particularly noticeable in any form of loop that quickly iterates through the values.

In order to work around this issue, you can call the .NET method GC.Collect, or to "reset" the condition that can lead to the error. Simply insert the garbage collection method in the loop so it runs on the 8th or 9th iteration, and the error should not occur, and the workaround shouldn't cause noticeable performance issues.

Workarounds: GC.Collect method Or TimeScaleData Method from .NET without GC.Collect

[Source]