Value of TimeScaleData is unknown?

B

brennen.milam

Greetings - I am importing data from a CSV file that contains timesheet
information - thus updating ActualWork and ActualCost for an assignment
in Project. I am writing this as a COM AddIn using VB.NET and MS
Project 2002 Pro.

When I try to set the ActualWork property for the TimeScaleData, I
occasionally get the error "An Unexpected Error Occured Within the
method" for the Value field. This occurs on a somewhat random basis
and I am stumped at the moment.

A rough sample of the code: (sorry about the poor formatting in this
post)

Dim tsvActualWork as MSProject.TimeScaleValue

tsvActualWork =
AppInstance.ActiveProject.Resources.UniqueID(intResourceUniqueID).Assignments(intAssignmentIndex).TimeScaleData(
ChargeDate, ChargeDate,
MSProject.PjAssignmentTimescaledData.pjAssignmentTimescaledActualWork,
MSProject.PjTimescaleUnit.pjTimescaleWeeks).Item(1)

tsvActualWork.Value = intHours

Does anyone know why this particular error is occuring? It is not
always at the same place and I have been unable to determine why/when
it happens. Any help would be much appreciated as I am new to
automation with MS Project.


Brennen Milam
 
J

Jan De Messemaeker

Hi,

When the tsv does not span any working time (such as in day by day you cover
a Sunday)
 
R

Rod Gill

Hi,

Better code is:

Dim tsvActualWorks as MSProject.TimeScaleValues
Dim tsvActualWork as MSProject.TimeScaleValue

set tsvActualWorks =
AppInstance.ActiveProject.Resources.UniqueID(intResourceUniqueID).Assignments(intAssignmentIndex).TimeScaleData( ChargeDate, ChargeDate, MSProject.PjAssignmentTimescaledData.pjAssignmentTimescaledActualWork, MSProject.PjTimescaleUnit.pjTimescaleWeeks) tsvActualWorks(1).Value = intHours*60 ' Value is in minutesIf ChargeDate is outside 1980 -2047 date range then teh process probablyfails. You need to single step thru the code and see what happens.--Rod GillProject MVPVisit www.msproject-systems.com for Project Companion Tools and more<[email protected]> wrote in messageGreetings - I am importing data from a CSV file that contains timesheet> information - thus updating ActualWork and ActualCost for an assignment> in Project. I am writing this as a COM AddIn using VB.NET and MS> Project 2002 Pro.>> When I try to set the ActualWork property for the TimeScaleData, I> occasionally get the error "An Unexpected Error Occured Within the> method" for the Value field. This occurs on a somewhat random basis> and I am stumped at the moment.>> A rough sample of the code: (sorry about the poor formatting in this> post)>> Dim tsvActualWork as MSProject.TimeScaleValue>> tsvActualWork =>AppInstance.ActiveProject.Resources.UniqueID(intResourceUniqueID).Assignments(intAssignmentIndex).TimeScaleData(> ChargeDate, ChargeDate,> MSProject.PjAssignmentTimescaledData.pjAssignmentTimescaledActualWork,> MSProject.PjTimescaleUnit.pjTimescaleWeeks).Item(1)>> tsvActualWork.Value = intHours>> Does anyone know why this particular error is occuring? It is not> always at the same place and I have been unable to determine why/when> it happens. Any help would be much appreciated as I am new to> automation with MS Project.>>> Brennen Milam>
 
B

brennen.milam

Thanks Jan and Rod for the reply. I stepped through the code and still
was unable to discover why the TimeScaleData.value was giving me an
error. It would work the first time I accessed the
TimeScaleValue.value for a given assignment. Then if I tried to access
the same value field again I got a ComException error "An Unexpected
Error Occured Within the method". This happened on a very inconsistant
basis and at times when I *knew* the value was legit.

So I dug deeper into the forums and unvocered this:
<http://www.projectserverexperts.com/Shared Documents/SolveCOMExceptionError.htm>

There are also a number of older post from last year with similar
errors on the TimeScaleValue.Value field. It seems there is an
"internal resource limit in Microsoft Project" and "the .NET garbage
collector does not clear up the references fast enough" when the
TimeScaleData is accessed within a loop from VB.net or C#.

Therefore a simple solution is to simply add a System.GC.Collect() call
to manually force garbage collection. This has fixed the error for me.


Thanks,
Brennen
 

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