[英]sql ce native exception 0xc0000005
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: 当我运行从ms sql ce读取一些数据的.net 3.5 cf应用程序时,有时会收到带有以下信息的本机异常:
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: 我的GetDadosAEnviar查询非常简单:
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 如您在先前的研究中所看到的,我被指示这可能是线程之间的同步问题,因此我将lock语句与
private static object lockObj=new object();
But the problem is when it calls the GetDadosAEnviar. 但是问题是当它调用GetDadosAEnviar时。 What i can do to correct this behavior? 我可以做些什么来纠正这种行为?
UPDATE 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. 该错误是由sqlce本机dll损坏引起的。 By uninstalling and re-installing the sqlce everything worked. 通过卸载并重新安装sqlce,一切正常。 Better yet it is quicker, because of the time spent on optimizing the flow of code, instead of using stock VS boilerplate code 更好的是,它更快,因为花费了时间来优化代码流,而不是使用库存VS样板代码
I had exactly the same error and was pulling my hair out with frustration, not getting anywhere. 我有完全相同的错误,并且沮丧地把头发拔了出去,没到任何地方。 I references the SQL CE dlls directly and copied them all to the device during deploy, so after I read the above solution I tried to remove all the files and redeploy from scratch. 我直接引用了SQL CE dll,并在部署期间将它们全部复制到了设备上,因此在阅读上述解决方案后,我尝试删除所有文件并从头开始重新部署。 That also did not work. 那也没有用。 In the end I installed SQL Server CE 3.5 SP2 directly on to the device with the CAB file found in 最后,我使用以下目录中的CAB文件将SQL Server CE 3.5 SP2直接安装到设备上
C:\\Program Files (x86)\\Microsoft SQL Server Compact Edition\\v3.5\\Devices\\wce500\\armv4i\\sqlce.wce5.armv4i.cab C:\\ Program Files(x86)\\ Microsoft SQL Server Compact Edition \\ v3.5 \\ Devices \\ wce500 \\ armv4i \\ sqlce.wce5.armv4i.cab
(ARMv4 in my case, your's may vary). (在我的情况下,ARMv4可能有所不同)。 After installing this to the device everything ran fine. 将其安装到设备后,一切运行正常。
Is the SqlCeConnection being used at the same time on another thread? 是否在另一个线程上同时使用SqlCeConnection?
If that is the case, you may need a lock there too. 如果是这种情况,您可能也需要在那儿加锁。 To test, make a new connection (temporarily) and see if it fixes it. 要进行测试,请临时建立一个新连接,然后查看它是否可以解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.