MS Project TimeScaleValue COMException Workaround

B

Brook Miles

I recently ran up against this problem and found that while there were
several posts about it spanning years, nobody seems to have posted a
solution.

Calling TimeScaleData returns a TimeScaleValues collection containing
TimeScaleValue items. When iterating through the returned list in C#
or VB.NET and accessing the Value member of each item, a COMException
will be thrown on the 10th item.

Aparently there is an internal resource limit in Project which
prevents holding references to more than 9 TimeScaleValue objects at
the same time, and the .NET garbage collector is not clearing up the
references fast enough.

A work-around for this is to force the garbage collector to clean up
its references after each execution of the loop. Placing a call to
System.GC.Collect() at the end of the loop appears to solve the
problem.

This is not an elegant solution, but it does work. Thanks to Shaun
Ivory at Microsoft for assisting me in diagnosing this problem.

Brook Miles
Replicon, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top