on 12-22-2005 2:20 AM
-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?
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.