Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
other
informationbridge
office.intranets
office.misc
office.setup
office.xml
officeupdate
onenote
photodraw.discussion
powerpoint
producer
proj.standard&server
project
project.developer
project.pro_and_serve
project.server
project.vba
project2000
publisher
publisher.prepress
publisher.programming
publisher.webdesign
visio
visio.createshapes
visio.database.modeling
visio.dev.diagrams
visio.dev.shapesheet
visio.dev.vba
visio.dev.vc
visio.developer
visio.general
visio.installation
visio.printing
visio.software.modeling
visio.troubleshoot
  
 
date: Thu, 10 Jul 2008 10:00:03 -0700,    group: microsoft.public.project.developer        back       


Timescale Data via C#   
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
    }

  }

}
date: Thu, 10 Jul 2008 10:00:03 -0700   author:   gvolp am

RE: Timescale Data via C#   
A few things to try:

Use Try / Catch to recover from the error or display some further 
information to troubleshoot with. If the problem is that it is just running 
out of values then resuming the next tsv would be a reasonable solution. It 
is hard to know without seeing your project data and the values that are 
returned.

Try using VB instead of C#. It may be a bug in the C# implementation. VB is 
also a bit easier to code when you are porting over VBA. Optional parameters 
can be omitted, most VBA code can come over with very minor changes.

Those are the points where I'd start troubleshooting.

-Jack Dahlgren


"gvolp" wrote:

> 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
>     }
> 
>   }
> 
> }
>
date: Thu, 10 Jul 2008 10:54:01 -0700   author:   Jack Dahlgren

RE: Timescale Data via C#   
Jack,

Thanks for your reply. In my original code (i posted a short snippet) I have 
exception handling included. What occurs is the dreaded "unexpected error has 
occurred 
with the method". If I catch the exceptions, it just keeps throwing them 
till the end of the iteration has been reached. I know there is data beyond 
the current timescale value (the vba code produces it just fine).  I am aware 
of the "" returned and  handle them fine. I have tried multiple projects with 
more than 10 values (in this case pjTimescaleDays) and they all throw this 
error so it is not project specific. If your up for it and have VS2007 
installed, I could send you an mpp file and a simple test project I created 
to reproduce the error.

I tried using VB.Net and it gave me the same error. This leads me to believe 
its in the combination of Projects COM implementation and/or the .Net 3.5 
framework implementation?

I'm perplexed. Thanks for answering.

Greg

"Jack Dahlgren" wrote:

> A few things to try:
> 
> Use Try / Catch to recover from the error or display some further 
> information to troubleshoot with. If the problem is that it is just running 
> out of values then resuming the next tsv would be a reasonable solution. It 
> is hard to know without seeing your project data and the values that are 
> returned.
> 
> Try using VB instead of C#. It may be a bug in the C# implementation. VB is 
> also a bit easier to code when you are porting over VBA. Optional parameters 
> can be omitted, most VBA code can come over with very minor changes.
> 
> Those are the points where I'd start troubleshooting.
> 
> -Jack Dahlgren
> 
> 
> "gvolp" wrote:
> 
> > 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
> >     }
> > 
> >   }
> > 
> > }
> >
date: Fri, 11 Jul 2008 12:48:00 -0700   author:   gvolp am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us