on 04-23-2015 9:14 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
8 | |
8 | |
5 | |
4 | |
3 | |
3 | |
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.