VB.Net: Com exception "An unexpected error occurred with the metho

M

Maarteke

Hi,

I have a problem whith an MS Project 2003 COM Addin written in VB.net

In my code, I want to retrieve the work for each assignment for each month:

timeScaleValues = assignment.TimeScaleData(fromDate, Enddate ,
pjResourceTimescaledWork, pjTimescaleMonths, 1)
For Each timeScaleValue In timeScaleValues
MyObject.Add(timeScaleValue.Value)
Next

If i run this code, i get the com exception "An unexpected error occurred
with the method"
This seems to be because of a resource limit in MS Project:
http://www.projectserverexperts.com/Shared Documents/SolveCOMExceptionError.htm

If i change my code to it works:
timeScaleValues = assignment.TimeScaleData(fromDate, toDate,
pjResourceTimescaledWork, pjTimescaleMonths, 1)
For Each timeScaleValue In timeScaleValues
MyObject.Add(timeScaleValue.Value)
If GBCounter = 7 Then
GBCounter = 0
GC.Collect()
Else
GBCounter += 1
End If
Next

The garbage collection of course slows down my add-in.
Can i free my timescaleValue objects without having to call GC.Collect?
 
J

Jan De Messemaeker

Hi Maarteke,

Maybeb it's because I use VBA and not VB, but I'm not familiar with GC and
GBcounter.
Am I supposed to?
Not knowing what Myobject is, are you aware that such a timescalevalue can
be null? it's always advisable to use
Val(timescval.value)

Hope this helps,
 
M

Maarteke

Hi,

Thanks for the quick reply, Jan!

The code i pasted was more or less pseudo code:
-GBCounter is an integer initialised to 0
-GC.Collect() is a Call to the .Net garbage collector
-The myObject.add() was an example. In my code, i check whether or not the
value equals ""

The code is working, but is very slow due to the garbage collection

Hope this clarifies,

Maarten
 
J

Jan De Messemaeker

Hi,

Well, I don't know the garbage collector (unknown in VBA); I still advise to
use
Val(TSV.value) to avoid garbage at all.
HTH
 

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