cancel
Showing results for 
Search instead for 
Did you mean: 

-1120 - Ref count for this object is higher then 0

Former Member
0 Kudos

-1120 - Ref count for this object is higher then 0

I get this error when adding an object from XML, however if I run the exact same code again on the application it works?

Anyone experienced anything like this?

Accepted Solutions (1)

Accepted Solutions (1)

barend_morkel2
Active Contributor
0 Kudos

Hi Daniel,

This error normaly occurs when using metadata objects. (When adding tables and fields and UDO's). SBO only allows 1 connection to such an object. I don't know what you are attempting to do, but it's always "wise" to kill objects that you are finished with before instanciating new ones (saves on memory etc.). Thus I will show you what I do and maybe if you are more specific in creation and killing of objects your problem will be solved. My demo is in VB .Net.

'1. Add a table using SAPbobsCOM.UserTablesMD object

Dim oUTables As SAPbobsCOM.UserTablesMD

'Create Instance of UserTablesMD object

oUTables = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)

'Add the table code .....................

'NOW to KILL the object

' IMPORTANT: Only one (“handle to a”) user table or field object should be alive

' at one time!!! -> In .NET call this first

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

'Then set object variable to Nothing…

oUTables = Nothing

GC.Collect() 'Call the garbage collector for good measure

'2. Add a field using SAPbobsCOM.UserFieldsMD object

Dim oUFields As SAPbobsCOM.UserFieldsMD

'Create Instance of UserFieldsMD object

oUFields = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)

'Add the field code .....................

'NOW to KILL the object

' IMPORTANT: Only one (“handle to a”) user table or field object should be alive

' at one time!!! -> In .NET call this first

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

'Then set object variable to Nothing…

oUFields = Nothing

GC.Collect()

TRY THIS - MAYBE IT WORKS FOR YOU...

Former Member
0 Kudos

Hi Barend,

Indeed you are correct, I am working with userfields. I have implemented the code you suggest and have not experienced the error again!

Thanks very much for your post, and Merry Christmas

Daniel

Answers (1)

Answers (1)

Former Member
0 Kudos

It is also nice to know:

It is a condition for the usage of

Dim oUDT As SAPbobsCOM.UserTablesMD

oUDT = oDataIterface.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)

...

that all other BusinessObjects must be closed.

Example: Global hold BusinessObject-References

otherwise "-1120 - Ref count for this object is higher then 0"-Message arise!