SQL CE机异常0000005 [英] sql ce native exception 0xc0000005

查看:262
本文介绍了SQL CE机异常0000005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行我的.NET CF 3.5的应用程序,从MS SQL CE读取一些数据,有时我出现以下信息的本地异常:

  ExceptionCode:0000005 
ExceptionAddress:0x44746e65(变量)
阅读:0x44746e64

在NativeMethods.GetKeyInfo(IntPtr的PTX,字符串pwszBaseTable,IntPtr的prgDbKeyInfo,的Int32 cDbKeyInfo ,IntPtr的PERROR)
$在SqlCeCommand.ExecuteReader(CommandBahavior行为)

(b $ b ...不再赘述)

在dadosGpsTableAdapter.GetDadosAEnviar()

我GetDadosAEnviar查询是非常简单的:

  SELECT _id,经纬度,Ignicao,海拔高度,Velocidade,Direcao,Qualidade,时间戳,Valido,Enviado,CondutorID 
FROM DadosGps
WHERE(Enviado = 0)

和代码调用此查询是:

 私人布尔SendRemainingData()
{
SetCurrentStatus(A投递历史一);

{

锁(lockObj)
{
DadosDataSet.DadosGpsDataTable dadosAEnviar = gpsAdapter.GetDadosEnviar();

如果(dadosAEnviar.Rows.Count大于0)
{

的foreach(在dadosAEnviar.Rows DadosDataSet.DadosGpsRow amostra)
{
布尔resultado = webServicesGps.SendToServerGPSData(IMEI,amostra.Timestamp,amostra.Latitude,amostra.Longitude,Convert.ToDecimal(amostra.Altitude),
Convert.ToDecimal(amostra.Velocidade),Convert.ToDecimal(amostra .Direcao),新布尔[] {} amostra.Ignicao,decimal.Zero,Convert.ToDecimal(amostra.Qualidade),);

如果(resultado)
gpsAdapter.RegistarEnvio(amostra._id);
}
}
dadosAEnviar.Dispose();
}

(...不再赘述)



正如你可以看到以前的研究,我有人指出,这可能是线程间的同步问题,所以我用锁语句的

 私有静态对象lockObj =新的对象(); 



但问题是,当它调用GetDadosAEnviar。我能做些什么来纠正这种行为?



更新



更广泛的debbuging后,我陷害导致异常的代码,它是在自动生成的代码VS创建:

  this.Adapter.SelectCommand = this.CommandCollection [3]; 
DadosDataSet.DadosGpsDataTable的dataTable =新DadosDataSet.DadosGpsDataTable();
//下一行barfs一机异常
this.Adapter.Fill(dataTable的);
dataTable的回报;


解决方案

解决它



该错误是由SQLCE机DLL的损坏引起的。通过unistalling并重新安装SLCE一切工作。更重要的是它是因为optmizing的码流,而不是使用股票VS样板代码


时间STEMP更快,

When i run my .net 3.5 cf application that reads some data from ms sql ce, sometimes i get an native exception with the following info:

ExceptionCode: 0xc0000005
ExceptionAddress : 0x44746e65 (variable)
Reading: 0x44746e64

at NativeMethods.GetKeyInfo(IntPtr pTx, String pwszBaseTable, IntPtr prgDbKeyInfo, Int32 cDbKeyInfo, IntPtr pError)

at SqlCeCommand.ExecuteReader(CommandBahavior behavior)

(... omitted for brevity)

at dadosGpsTableAdapter.GetDadosAEnviar()

My GetDadosAEnviar query is very simple:

SELECT        _id, Latitude, Longitude, Ignicao, Altitude, Velocidade,Direcao, Qualidade, Timestamp, Valido, Enviado, CondutorID
FROM            DadosGps
WHERE        (Enviado = 0)

and the code that calls this query is:

private bool SendRemainingData()
    {
        SetCurrentStatus("A Enviar historico");
        try
        {

            lock (lockObj)
            {
                DadosDataSet.DadosGpsDataTable dadosAEnviar = gpsAdapter.GetDadosEnviar();

                if (dadosAEnviar.Rows.Count > 0)
                {

                    foreach (DadosDataSet.DadosGpsRow amostra in dadosAEnviar.Rows)
                    {
                        bool resultado = webServicesGps.SendToServerGPSData(IMEI, amostra.Timestamp, amostra.Latitude, amostra.Longitude, Convert.ToDecimal(amostra.Altitude),
                            Convert.ToDecimal(amostra.Velocidade), Convert.ToDecimal(amostra.Direcao), new bool[] { amostra.Ignicao }, decimal.Zero, Convert.ToDecimal(amostra.Qualidade), "");

                        if (resultado)
                            gpsAdapter.RegistarEnvio(amostra._id);
                    }
                }
                dadosAEnviar.Dispose();
            }

(... omitted for brevity)

As you can see for the previous research i was indicated that it could be an sync issue between threads, so i use the lock statement with an

private static object lockObj=new object();

But the problem is when it calls the GetDadosAEnviar. What i can do to correct this behavior?

UPDATE

After more extensive debbuging i framed the code that causes the exception, it's on the auto-generated code vs creates:

this.Adapter.SelectCommand = this.CommandCollection[3];
        DadosDataSet.DadosGpsDataTable dataTable = new DadosDataSet.DadosGpsDataTable();
        //Next line "barfs" an native exception
        this.Adapter.Fill(dataTable);
        return dataTable;

解决方案

SOLVED IT

The error was caused by corruption of the sqlce native dll. By unistalling and re-installing the slce everything worked. Better yet it is quicker, because of the time stemp on optmizing the flow of code, instead of using stock VS boilerplate code

这篇关于SQL CE机异常0000005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆