我如何绕过"80004005有文件共享冲突...."SQL Server CE数据库上的错误消息吗? [英] How can I circument the "80004005 There is a file sharing violation...." err msg on a SQL Server CE database?

查看:62
本文介绍了我如何绕过"80004005有文件共享冲突...."SQL Server CE数据库上的错误消息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到错误

80004005存在文件共享冲突.使用该文件的过程可能有所不同.

当尝试打开 SqlCeConnection 时.

是否有办法以编程方式关闭SQL Server CE数据库,以试图解决这一问题呢?类似于(伪代码):

  SqlCeDatabase SQLCeDb ="\我的文档\ HHSDB003.sdf";如果(SQLCeDb.IsOpen){SQLCeDb.Close();} 

?

或设置连接方式的一种方法,以使它不在乎数据库是否在其他位置/明智地打开,例如:

  SqlCeConnection conn =新的SqlCeConnection(@数据源= \我的文档\ HHSDB003.sdf;文件模式='共享读取')); 

...或:

  SqlCeConnection conn =新的SqlCeConnection(@数据源= \我的文档\ HHSDB003.sdf;文件模式='读写'")); 

我目前无法测试这些,因为我已经恢复使用

无法复制HHS.exe设备已停止响应或已断开连接

当我尝试将新版本的.exe复制到手持设备时.

如果要进行比Windows CE/Compact Framework/.NET的史前版本更令人沮丧的编程(我认为反对"在这里是正确的词),那么我不确定我是否想知道是什么.

更新

除了我的困惑(混乱和沮丧的干草堆组合),我在 http://www.pocketpcfaq.com/faqs/activesync/exchange_errors.php :

  0x80004005不适用由于设备软件错误,同步失败.与您的网络管理员联系.1.从服务提供商处获取最新的Pocket PC最终用户更新. 

更新2

这可能有问题吗(除了第一个设置为空以外,其他所有条件除外):

更新3

使用以下代码:

  private void menuItemTestSendingXML_Click(对象发送者,System.EventArgs e){string connStr =数据源=我的文档\\ HHSDB003.SDF";SqlCeConnection conn = null;尝试{尝试{conn =新的SqlCeConnection(connStr);conn.Open();MessageBox.Show(必须已经打开了");}最后{conn.Close();}}抓住(前例外){如果(null == ex.InnerException){MessageBox.Show(内部Ex为null");}MessageBox.Show(String.Format("msg为{0}",例如Message));}} 

...我现在看到它一定已经打开好了"(这是一件好事,但是...为什么它现在可以工作,我不知道,因为自从我上次运行它以来,代码没有更改,失败了.代码之外的东西一定在起作用.

我想到的唯一一件事情可能是与这一变化有关的,就是我认为手持设备的内存中可能存在.exe或其辅助dll的流氓实例,我写道一个快速且肮脏的实用程序,它遍历正在运行的进程,寻找它们,如果找到它们,则将其杀死,但是它们不存在,因此该实用程序实际上什么也没做"(也许是霍桑效应?).

尽管如此,使用这种工具和技术组合的方式似乎仍然可行:一分钟一切正常,然后BAM一切正常!它不再是.然后,相反的情况也可能发生:没有明显的原因,它似乎可以自我修复".

为了全面披露",以下是实用程序代码:

 //从http://www.codeproject.com/Articles/36841/Compact-Framework-Process-class-that-supports-full获得了私有无效btnKillRogue_Click(对象发送者,EventArgs e){ProcessInfo []列表= ProcessCE.GetProcesses();foreach(列表中的ProcessInfo项){MessageBox.Show(处理项:" + item.FullPath);if(item.FullPath == @"\ Windows \ iexplore.exe")item.Kill();//< =这是示例搜索;可能是个问题,所以我也会用如果(item.FullPath.EndsWith("HHS.exe")){MessageBox.Show(即将杀死hhs.exe");item.Kill();}如果(item.FullPath.EndsWith("HUtilCE.dll")){MessageBox.Show(即将杀死hutilce.dll");item.Kill();}}} 

也许存在驻留在内存中的iexplore.exe实例有问题(如果找到的话,我没有显示消息框)...?

解决方案

作为试图索取未用赏金的尝试……但是,不必以我的名义绕开免费积分...

除了强行杀死可能的任务外,您是否还在寻找答案的过程中重新启动了系统?如果您的工具未返回消息,则很可能重启可能会完成您尝试使用kill实用程序所做的事情-否则iexplore.exe可能与之有关...缺少其他功能消息框可能会让您永远不知道-除非再次发生此问题.

如果没有重新启动,则也许其他程序在内存中保存的程序/dll结束了其任务并释放了它.

可能发生了几种情况,绝对很难确定.因此缺乏答案.不过,如果再次出现此问题,我会很感兴趣.

I am getting error

80004005 There is a file sharing violation. A different process might be using the file.

when trying to open a SqlCeConnection.

Is there a way to close a SQL Server CE database programmatically, to try to nip that problem in the bud? Something like (pseudocode):

SqlCeDatabase SQLCeDb = "\My Documents\HHSDB003.sdf";

if (SQLCeDb.IsOpen)
{
    SQLCeDb.Close();
}

?

Or a way to set the connection so that it doesn't care if the database is open elsewhere/wise, such as:

SqlCeConnection conn = new SqlCeConnection(@"Data Source=\My Documents\HHSDB003.sdf;File Mode = 'shared read'");

...or:

SqlCeConnection conn = new SqlCeConnection(@"Data Source=\My Documents\HHSDB003.sdf;File Mode = 'read write'");

I can't test these at present, because I'm back to getting

Cannot copy HHS.exe The device has either stopped responding or has been disconnected

when I attempt to copy over a new version of the .exe to the handheld.

If there's something more frustrating to program against (and "against" is the correct word here, I think) than the prehistoric versions of Windows CE / Compact Framework / .NET, I'm not at all sure I want to know what it is.

UPDATE

Adding to my frustrusion (haywire combination of confusion and frustration), I found the following at http://www.pocketpcfaq.com/faqs/activesync/exchange_errors.php:

    0x80004005  N/A Synchronization failed due to a device software error. Contact your network administrator.      

1. Obtain the latest Pocket PC End User Update from your service provider.

UPDATE 2

Is this possibly problematic (than all but the first setting is blank):

UPDATE 3

With this code:

private void menuItemTestSendingXML_Click(object sender, System.EventArgs e)
{
    string connStr = "Data Source=My Documents\\HHSDB003.SDF"; 

    SqlCeConnection conn = null;

    try
    {
        try
        {
            conn = new SqlCeConnection(connStr);
            conn.Open();
            MessageBox.Show("it must have opened okay");
        }
        finally
        {
            conn.Close();
        }
    }
    catch (Exception ex)
    {
        if (null == ex.InnerException)
        {
            MessageBox.Show("inner Ex is null");
        }
        MessageBox.Show(String.Format("msg is {0}", ex.Message));
    }
}

...I am now seeing "it must have opened okay" (that's a good thing, but...why it's now working, I have no idea, because the code has not changed since I last ran it and it failed. Something beyond the code must have been at play.

The only thing I can think of that happened that MAY have had a bearing on this change is that, thinking there may have been a rogue instance of either the .exe or its ancillary dll in memory on the handheld device, I wrote an quick-and-dirty utility that looped through the running processes, looking for them and, if finding them, killing them, but they were not there, so the utility really did "nothing" (maybe the Hawthorne effect?).

That is the way working with this combination of tools and technologies seems to go, though: everything is working fine one minute and the next, BAM! It no longer is. Then the reverse can also happen: for no apparent reason it seems to "heal itself".

In the interests of "full disclosure," here is the utility code:

// Got this from http://www.codeproject.com/Articles/36841/Compact-Framework-Process-class-that-supports-full
private void btnKillRogue_Click(object sender, EventArgs e)
{
    ProcessInfo[] list = ProcessCE.GetProcesses();

    foreach (ProcessInfo item in list)
    {
        MessageBox.Show("Process item: " + item.FullPath);
        if (item.FullPath == @"\Windows\iexplore.exe") item.Kill(); //<= this was the example search; it probably could be a problem, so I'll use it, too
        if (item.FullPath.EndsWith("HHS.exe"))
        {
            MessageBox.Show("about to kill hhs.exe");
            item.Kill();
        }
        if (item.FullPath.EndsWith("HUtilCE.dll"))
        {
            MessageBox.Show("about to kill hutilce.dll");
            item.Kill();
        }
    }
}

Maybe there was an instance of iexplore.exe resident in memory that was problematic (I'm not showing a messagebox if that is what is found)...?

解决方案

As an attempt to claim unused bounty ... do not, however, feel obligated to pass around free points on my behalf ...

Aside from force killing of possible tasks, had you rebooted the system amidst your search for an answer? If your tool did not return the message, it is certainly possible that a reboot would have done the very thing that you had attempted with the kill utility - or possible iexplore.exe had something to do with it ... the lack of the additional messagebox may leave you never knowing - unless this issue occurs again.

If no rebooting occurred, then perhaps whatever program/dll was held in memory by some other process concluded its task and released it hold.

There are several scenarios that might have occurred, it is certainly hard to determine with absolution; hence the lack of answers. I would be interested, though, if this problem occurred again.

这篇关于我如何绕过"80004005有文件共享冲突...."SQL Server CE数据库上的错误消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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