H
Hans-Henrik Olesen
Hi!
I'm attempting to insert work from our time registration system into plan.
I have created an addin that does this by getting the data from a
webservice and inserting the values in to the active plan, but I get a
"An unexpected error occurred with the method" com exception after
inserting a few times.
I've heard of problems with the reference count (Project only capable of
handling 10 references to an object) and have unsuccessfully tried to
compensate for this by active garbagecolletion
I have also experimented with the type of the object I'm inserting - so
far, strings have been the best choice.
The following code generate an exception after 10 insertions (i == 10),
if I open a plan with one task in it and then run the code.
The start and end date of the task have no influence on the result.
Any help with this problem is appreciated.
Hans-Henrik Olesen
private void VersionButton_Click(CommandBarButton Ctrl, ref bool
CancelDefault)
{
for(int i = 0; i< 40; i++)
{
InsertValue("8", new DateTime(2004, 08, 25).AddDays(i));
//System.GC.Collect();
}
}
private void InsertValue(string value, DateTime date)
{
MSProject.Project CurrentProject = CurrentApplication.ActiveProject;
MSProject.Task tsk = CurrentProject.Tasks[1];
MSProject.TimeScaleValues TSVs = tsk.TimeScaleData(date, date,
MSProject.PjTaskTimescaledData.pjTaskTimescaledActualWork,
MSProject.PjTimescaleUnit.pjTimescaleDays, 1);
MSProject.TimeScaleValue TSV = TSVs[1];
try
{
TSV.Value = value;
}
catch(Exception exp)
{ MessageBox.Show(
exp.StackTrace.ToString());
}
}
I'm attempting to insert work from our time registration system into plan.
I have created an addin that does this by getting the data from a
webservice and inserting the values in to the active plan, but I get a
"An unexpected error occurred with the method" com exception after
inserting a few times.
I've heard of problems with the reference count (Project only capable of
handling 10 references to an object) and have unsuccessfully tried to
compensate for this by active garbagecolletion
I have also experimented with the type of the object I'm inserting - so
far, strings have been the best choice.
The following code generate an exception after 10 insertions (i == 10),
if I open a plan with one task in it and then run the code.
The start and end date of the task have no influence on the result.
Any help with this problem is appreciated.
Hans-Henrik Olesen
private void VersionButton_Click(CommandBarButton Ctrl, ref bool
CancelDefault)
{
for(int i = 0; i< 40; i++)
{
InsertValue("8", new DateTime(2004, 08, 25).AddDays(i));
//System.GC.Collect();
}
}
private void InsertValue(string value, DateTime date)
{
MSProject.Project CurrentProject = CurrentApplication.ActiveProject;
MSProject.Task tsk = CurrentProject.Tasks[1];
MSProject.TimeScaleValues TSVs = tsk.TimeScaleData(date, date,
MSProject.PjTaskTimescaledData.pjTaskTimescaledActualWork,
MSProject.PjTimescaleUnit.pjTimescaleDays, 1);
MSProject.TimeScaleValue TSV = TSVs[1];
try
{
TSV.Value = value;
}
catch(Exception exp)
{ MessageBox.Show(
exp.StackTrace.ToString());
}
}