cancel
Showing results for 
Search instead for 
Did you mean: 

When get oBusinessPartners Object Error The server threw an exception. (Exception from HRESULT: 0x80010105)

Former Member
0 Kudos

try

{

     BusinessPartners oBp = (BusinessPartners)objCompany.GetBusinessObject(BoObjectTypes.oBusinessPartners);

}

catch (Exception exception)

{

     Log4.Error("Error:", exception);

}

System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

   at SAPbobsCOM.ICompany.GetBusinessObject(BoObjectTypes Object)

   at Satrack.Provider.Rules.InternalDev.Core.Handler.RazonSocial.ActualizarDatosSap(String nit, String value, Int32 idPais) in F:\Biblioteca de servicios\Main\Satrack.Provider.Rules.InternalDev\Satrack.Provider.Rules.InternalDev.Core\Handler\RazonSocial.cs:line 151

Please help me to solve problem

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

The exception is unusual. It usually occurs once a month. I use the Singleton pattern.

public static Company Instance

{

    get{

            if (_instance == null)

            {

                //Log4.Info("Instancia nula");

                lock (LockObject)

                {

                    if (_instance == null)

                    {

                        _instance = new Singleton().objCompany();

         

                    }

                }

            }

        return _instance; 

    }

}

private Company objCompany()

{

    int code = 1;

    string error = "";

    var objCompany = new Company();

    string serverName = ConfigurationManager.AppSettings["ServerNa

    var companyDb = ConfigurationManager.AppSettings["companyDBSAP

    try

    {

        //objCompany.UseTrusted = true;

        objCompany.Server = serverName;

        objCompany.CompanyDB = companyDb;

        //objCompany.CompanyDB = "********";

        objCompany.UserName = "*********";

        objCompany.Password = "**********";

        objCompany.DbServerType = BoDataServerTypes.dst_MSSQL2012;

        objCompany.language = BoSuppLangs.ln_English;

        code = objCompany.Connect();

        error = objCompany.GetLastErrorDescription();

    }

    catch (CoreException coreException)

    {

        coreException.Message.GetType();

    }

    if (code != 0)

    {

        Log4.Info(error);

        return null;

    }

    return objCompany;

}

In this method I update my database. It usually works correctly but sometimes appears exception.

public string ActualizarDatosSap(string nit, string value)

{

    string respuesta;

    var objCompany = Base.Singleton.Instance;

    try

    {

        if (objCompany == null || !objCompany.Connected)

        {

            throw new CoreException(Resources.CoreResources.ExceptionConectarSAP);

        }

        var oBp = (BusinessPartners)objCompany.GetBusinessObject(BoObjectTypes.oBusinessPartners);

        oBp.GetByKey(nit);

        var count = oBp.UserFields.Fields.Count;

        for (var i = 0; i < count; i++)

        {

            switch (oBp.UserFields.Fields.Item(i).Name)

            {

                case "U_SATRACK_Estado":

                    oBp.UserFields.Fields.Item(i).Value = value;

                    break;

                case "U_FechaUltCambioEst":

                    oBp.UserFields.Fields.Item(i).Value = DateTime.Now;

                    break;

            }

        }

        oBp.Update();

        respuesta = objCompany.GetLastErrorDescription();

    }

    catch (Exception exception)

    {

        Log4.Error("Error:", exception);

    }

    return respuesta;

}

Thanks

edy_simon
Active Contributor
0 Kudos

hi Camilo,

s this code part of a service or web application?

regards

edy

Former Member
0 Kudos

Hi Edy,

It is a web service.

Thanks

edy_simon
Active Contributor
0 Kudos

Hi Camilo,

I can only say that DIAPI is not the best solution for service type application.

reason is it leaks memory. when it reach a limit, windows will 'shut down' the object and errors will happen like the one you are facing.

not to mention that before 91, the di api is not thread safe.

there is no easy solution for this,

the easiest is you decouple your service and the worker that references DI API.

the best is change the technology you used to di server/b1ws/b1if

regards

edy

Former Member
0 Kudos

Hi,

A common scenario for such problem is if your SQL server had re-started or re-connected during service is running.

The connection is obviously down, but the Company.Connected property does not recognize it and returns True although it's actually disconnected.

Beni.

edy_simon
Active Contributor
0 Kudos

Hi Camilo,

SOP :

1. Remove away the SM_OBS_DLL and SM_OBS_DLL_64

2. In your project, make sure your Interop.SAPbobsCOM.dll property : Copy Local = True, Embed Interop Types = false

3. If above does not solve, re-install the DI API, clean your project and re-reference your DI API.

Regards
Edy

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ,

Make sure that your company object is initialized properly. Means make sure that you are connected to the company.

Also you should be using the same DIAPI version as on your Server.

On this path:

C:\Program Files (x86)\SAP\SAP Business One DI API\Conf

Open b1-local-machine.xml in Notepad and check that your Server address is correct.

leaf kind="single" name="LicenseServer" type="String">

                <value>YOURSERVERADDRESS:30000</value>

Hope it helps.

Thanks & Regards

Ankit Chauhan