C#服务"该netwerk BIOS命令限制已达到"错误原因和最新最好的解决方案?最好的、命令、解决方案、错误

2023-09-07 10:32:04 作者:当时年少春衫薄i

我有打开多个观察者观看多个文件夹的服务。看完文件夹我得到了网络BIOS命令限制已经达到一定的时间。

当我阅读这里这是由于有更多的长期请求比允许的。

我认为出现这种情况是由于以下错误处理$ C $词都有,这是由观察家错误事件触发。这再次调用WatchFile方法启动观察者的新实例。我相信这会使老现已解散看守运行,并开始新的观察者,但恐怕停止观察者要么$ P $再次启动它pvent,或根据观察者将停止所有实例。

还是我错了,是错误取决于变化的数量?这将导致100个文件下降中的同时,以使该误差

我在想停止和启动服务,每当我在此错误运行,但这并不能解决问题本身而只是将其隐藏。有没有给它一个更好的解决办法?

 私有静态无效watcherError(字符串目录,布尔intray,ErrorEventArgs E,FileSystemWatcher的观察者)
{
    例外watchException = e.GetException();
    EventLog.WriteEntry(WhiteFileMover,String.Concat(错误gedetecteerd,观察家werd herstart  - ,watchException.Message),EventLogEntryType.Information);
    观察家=新FileSystemWatcher的();
    而(!watcher.EnableRaisingEvents)
    {
        尝试
        {
            //这将扔在了一个错误
            //如果不能获取路径watcher.NotifyFilter线。
            WatchFile(目录,intray);
        }
        赶上(例外EXP)
        {
            //睡眠了一下;否则,它需要多一点的
            //处理器时间
            EventLog.WriteEntry(WhiteFileMover,String.Concat(无法​​重新启动守望者,重试在5秒 - ,exp.Message),EventLogEntryType.Warning);
            System.Threading.Thread.Sleep(5000);
        }
    }
}
 

解决方案

看这句话:

 观察家=新FileSystemWatcher的();
 

您传递一个FileSystemWatcher的变量,但完全忽略了传递的值。相反,你创建了一个新的实例。不仅如此,但你无法正确处理实例。我的猜测是,你有一帮老FileSystemWatcher的物体挂在等待被收集。其中每一个都将坚持到一些真正的文件系统资源从操作系统。随着时间的推移,你用完了可用的文件句柄。

谁知道BIOS第一启动项设置为NetWork怎么用了

I have a service that opens multiple watchers to watch multiple folders. After watching folders for a certain amount of time I get the "The network bios command limit has been reached".

As I read on here this is caused by having more long term requests than allowed.

I believe this occurs due to the below error handling code i have, which is triggered by the watchers error event. This starts a new instance of the watcher by calling the WatchFile method again. I believe this leaves the old now defunct watcher running and starts a new watcher but i am afraid stopping the watcher will either prevent it from starting it up again or will stop all instances based on the watcher.

Or am I wrong and is the error dependent on the amount of changes? This would cause 100 files to drop in at the same time to cause this error.

I was thinking of stopping and starting the service whenever I run in this error but this would not solve the problem itself but just hide it. Is there a better solution to it?

private static void watcherError(String directory, Boolean intray, ErrorEventArgs e, FileSystemWatcher watcher)
{
    Exception watchException = e.GetException();
    EventLog.WriteEntry("WhiteFileMover", String.Concat("error gedetecteerd, watcher werd herstart  -  ", watchException.Message), EventLogEntryType.Information);
    watcher = new FileSystemWatcher();
    while (!watcher.EnableRaisingEvents)
    {
        try
        {
            // This will throw an error at the
            // watcher.NotifyFilter line if it can't get the path.
            WatchFile(directory, intray);
        }
        catch(Exception exp)
        {
            // Sleep for a bit; otherwise, it takes a bit of
            // processor time
            EventLog.WriteEntry("WhiteFileMover", String.Concat("Failed to restart watcher, retrying in 5 seconds  -  ", exp.Message), EventLogEntryType.Warning);
            System.Threading.Thread.Sleep(5000);
        }
    }
}

解决方案

Look at this line:

watcher = new FileSystemWatcher();

You passed in a FileSystemWatcher variable, but completely ignored the passed value. Instead, you created a new instance. Not only that, but you fail to correctly dispose the instance. My guess is that you have a bunch of old FileSystemWatcher objects hanging around waiting to be collected. Each of those will hold on to some real file system resources from the operating system. Over time, you run out of available file handles.

 
精彩推荐
图片推荐