cancel
Showing results for 
Search instead for 
Did you mean: 

DI Error -1120

Former Member
0 Kudos

Adding an activity type returns error -1120 (Ref count for this object is higher then 0) when other DI object references exist. The Add method fails in the following case:

Dim bp as SAPbobsCOM

Set bp = company.GetBusinessObject(oBusinessPartners)

dim o as SAPbobsCOM.ActivityTypes

o.Name = "ABC"

' Failure

o.Add

The Add method succeeds if the bp reference has been released:

Dim bp as SAPbobsCOM

Set bp = company.GetBusinessObject(oBusinessPartners)

Set bp = Nothing

dim o as SAPbobsCOM.ActivityTypes

o.Name = "ABC"

' Success

o.Add

According to the DI help, this is to be expected when attempting a metadata operation. Is adding an activity type a metadata operation? If not, is there a workaround that avoids having to release all DI object references? Thanks much.

Accepted Solutions (1)

Accepted Solutions (1)

barend_morkel2
Active Contributor
0 Kudos

Hi Dana,

You are right. Ref count for this object is higher then 0 is normally associated with a metadata operation. But there is a solution you can try. Put a try-finally block around each sub andd kill the objects in this way. (Obviously some object is hanging around, so you must kill it)

try

---your code

finally

System.Runtime.InteropServices.Marshal.ReleaseComObject(YourObject)

'Then set object variable to Nothing…

YourObject = Nothing

GC.Collect()

end

-


you can even run this code after using each object to make sure it is killed..

Answers (0)