System.DirectoryServices.DirectorySearcher 导致“算术运算导致溢出"错误 [英] System.DirectoryServices.DirectorySearcher causing "Arithmetic operation resulted in overflow" errors

查看:32
本文介绍了System.DirectoryServices.DirectorySearcher 导致“算术运算导致溢出"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下与使用以下方法查询 AD 相关的间歇性错误DirectorySearcher.FindOne()FindAll().

I'm getting the following intermittent errors related to querying AD using DirectorySearcher.FindOne() or FindAll().

System.OverflowException: Arithmetic operation resulted in an overflow.
     at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.GetCurrentResult()
     at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.get_Current()
     at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.System.Collections.IEnumerator.get_Current()

这是在网络应用中发生的,并且似乎是在应用运行了几个小时之后发生的.

This is happening in a web app and seems to happen after the app has been running for several hours.

这是 Microsoft 上的记录问题已连接,但它似乎已被标记为不可重现"并已关闭.

This is a documented issue on Microsoft Connect but it looks like it has been marked as "not reproducible" and closed.

我在此处找到的唯一解决方法是回收应用程序池定期执行此操作是一种相当苛刻的解决方法,并且当您的用户正在工作时不可行.

The only fix that I found here is to recycle the app pool periodically which is a rather harsh workaround and not viable when your users are in the middle of working.

有没有人遇到过这种情况,如果有,是如何解决的?

Has anyone experienced this and if so how was this resolved?

我曾尝试使用缓存,但这只会延迟不可避免的事情,直到您达到 AD 调用数量的某个阈值,因为人们报告说每次调用 API 时都会内存泄漏.

I have tried to use caching but this just delays the inevitable until you hit a certain threshold in terms of the number of AD calls since people have reported that each time the API call is made it leaks memory.

任何帮助将不胜感激.

推荐答案

构建 AD API 并在它自己的应用程序池中运行它.每隔几个小时回收一次.所有 API 将处理的是对 AD 的调用.看起来你已经有了代码,只需要移动到 API.我发现 AD API 对许多其他项目也非常有用,并继续将其作为参考点.

Build an AD API and run it in it's own app pool. The recycle that every few hours. All the API will handle is calls to AD. looks like you already have the code, just need to move to API. I have found a AD API to be very useful for lots of other projects as well and keep going back to it as reference point.

这篇关于System.DirectoryServices.DirectorySearcher 导致“算术运算导致溢出"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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