on 01-19-2006 8:06 PM
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.
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..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.