G
gvolp
I am writing a VSTO add in using C# in Visual Studio 2008 (with Beta SP1
installed). I am using Project Pro 2007 with SP1. Operating system XP Pro
with the latest service packs.
When I iterate over the timescaled values collection returned from
TimeScaleData (see code snippet below) about the tenth time into the
iteration the ts.Value throws an exception (“An unexpected error has occurred
with the method†the get_Value method.).
I have seen on several newsgroup threads that this is an issue with the
TimeScaleValues collection releasing resources prematurely. The same
iterative technique/code works fine from VBA.
How can I mark the TimeScaleValues object as “don’t release†or whatever I
need to do to make this work?
foreach (Microsoft.Office.Interop.MSProject.Resource rsc in
AppCfg.curPrj.Resources) {
foreach (Microsoft.Office.Interop.MSProject.Assignment assign in
rsc.Assignments) {
Microsoft.Office.Interop.MSProject.TimeScaleValues tsv =
assign.TimeScaleData(assign.Start, assign.Finish,
PjAssignmentTimescaledData.pjAssignmentTimescaledWork,
PjTimescaleUnit.pjTimescaleDays, 1);
foreach (Microsoft.Office.Interop.MSProject.TimeScaleValue ts in tsv) {
object obj = ts.Value
}
}
}
installed). I am using Project Pro 2007 with SP1. Operating system XP Pro
with the latest service packs.
When I iterate over the timescaled values collection returned from
TimeScaleData (see code snippet below) about the tenth time into the
iteration the ts.Value throws an exception (“An unexpected error has occurred
with the method†the get_Value method.).
I have seen on several newsgroup threads that this is an issue with the
TimeScaleValues collection releasing resources prematurely. The same
iterative technique/code works fine from VBA.
How can I mark the TimeScaleValues object as “don’t release†or whatever I
need to do to make this work?
foreach (Microsoft.Office.Interop.MSProject.Resource rsc in
AppCfg.curPrj.Resources) {
foreach (Microsoft.Office.Interop.MSProject.Assignment assign in
rsc.Assignments) {
Microsoft.Office.Interop.MSProject.TimeScaleValues tsv =
assign.TimeScaleData(assign.Start, assign.Finish,
PjAssignmentTimescaledData.pjAssignmentTimescaledWork,
PjTimescaleUnit.pjTimescaleDays, 1);
foreach (Microsoft.Office.Interop.MSProject.TimeScaleValue ts in tsv) {
object obj = ts.Value
}
}
}