Skip to Content
author's profile photo Former Member
Former Member

Error: -1120 , Reference count for this object is greater than 0"

I did a search on this but found nothing on it.

I sometimes get this error instead of "-2035, Table already exists" when trying to create a table and it already exists. Does anybody know the meaning of this error?

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 05:32 PM


    Owen, your suggestion is what we are already doing. In fact, we have a CreateTable function that incorporates it so that it is done every time we create a table in Business One.

    John, I added your idea so that when that function declares the oUserTablesMD object, it is immediately set equal to nothing. No help.

    Gianluigi, I added code to set the oUserTablesMD to Nothing before starting anything. No help.

    I need to describe when it is the error appears. We run the same code during the start up of our add-on if the database doesn't already have a table. During the startup, the code tries to add all the tables any way just to make sure they all are there; so we expect to get the -2035 error for the tables already there and we do. However, we have situations where we need to force the add-on to go through the database initiation process during add-on development. I usually do this by changing a line of code in the add-on startup so that the code runs. This has always worked. However, there are times when we need to allow the user to force a database init. That means that the add-on is already running. We added a button to the add-on’s options form do this. The error message only appears on the first time this button is clicked. If you click it a second time, the process runs without a hitch. In fact, you can click it many times and it works. It’s only on the first time that it gives this message. In addition, the process tries to add about ten tables; it is only on the first table that it fails. The statement that gets the error is the oCompany.GetLastError function. It appears that the oCompany object is confused the first time around about which object had the last error. One more piece of information is that because we have more than one add-on, we created a class library for code that is common among them. The function that creates the table is in that library. At add-on startup, the library’s company object is set equal to the same company that the add-on is connected to. But again, we get no error at startup.

    Any ideas?



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 17, 2008 at 04:20 AM

    Hi Mike,

    Are you garbage collecting any previous instance of the UserTableMD or UserFieldMD objects? The 'reference count' error normally occurs if a previous instance is still in memory.

    Try something like the following after you create each table or field:


    myObject = Nothing


    Kind Regards,


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 10, 2016 at 11:44 AM

    Mr. John Chadwick, Info advised. But for more details.

    While creating User Fields we will use two DI objects:-

    1) Record Set for the purpose of exist field or not from CUFD table.

    2) UserfieldMD Object for the purpose of create of field.

    Major reason behind creating error on this :-

    We were initialize Record Set Object simultaneously with UserFieldsMD.

    Error Effect

    -1120 Ref is higher than 0


    if(oRS.RecordCount = 0) then

    system,.Runtime,Interoperateservices.Marshal.Release.ComObject (oRS)

    oRS =Nothing


    oUDFMD = oCompany.GetBusinessObject(oUserFields)

    oUDFMD.TableName= ""

    oUDFMD.Name = ""



    lretcode = oUDFMD.Add()

    Repeat same steps of release com object code for OUDFMD.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.