Skip to Content
0
Former Member
Jan 04, 2012 at 04:50 PM

DIAPI Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)

2862 Views

We have an application written in C# that integrates several information on SAP B1 8.81: items, warehouses, several types of documents, etc.

This application is running as a service which periodically (typically every 5 minutes) runs the list of tasks that are configured to integrate.

The class has a variable that is shared for all methods:

public static SAPbobsCOM.Company company;

At the end of each task, we close the connection. At the beginning of each task, before creating a new connection, we run the same method to double-check if the connection is still open.

            try
            {
                if ((SAP.company != null) && (SAP.company.Connected))
                {
                    SAP.company.Disconnect();
                }
            }
            catch (Exception ex)
            {
                if (SAP.company != null)
                {
                    Marshal.ReleaseComObject(SAP.company);
                    SAP.company = null;
                }
                throw new Exception("Failed trying to close the connection to SAP: " + ex.Message);
            }

After this we create a new Company object and connect to SAP:

       SAP.company = new SAPbobsCOM.Company();
       [u2026 Fill connection parameters u2026]
      errCode = SAP.company.Connect();

This process is repeated for each and every task. We are getting an error on this method that occurs after some random period of time the service is running:

u201CThe server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))u201D

After this error has occurred the first time the service canu2019t connect to SAP anymore, the server keeps returning this error. We need to restart the service to reestablish the normal behavior.

Our software is integrating with several other ERPs and have never experienced a similar problem. We have tried several changes in the code, particularly releasing all COM objects after use, in order to prevent memory leaks, still with no success.

An help in trying to identify the cause and/or resolve this situation will be highly appreciated.