gpt4 book ai didi

c# - VS 2010 错误 "Value to add was out of range. Parameter name: value "

转载 作者:行者123 更新时间:2023-11-30 21:13:15 25 4
gpt4 key购买 nike

我遇到了一个奇怪的问题。我的 Web 应用程序抛出错误“要添加的值超出范围参数名称:值”。现在这不是我每次运行程序时都会出现这种情况。有时显示错误,有时运行没有问题(未完成任何更改)。错误下方给出的堆栈跟踪不清楚(至少对我而言)。有人遇到过这种问题吗?

错误详情

要添加的值超出范围。参数名称:值说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

Exception Details: System.ArgumentOutOfRangeException: Value to add was out of range.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ArgumentOutOfRangeException: Value to add was out of range.
Parameter name: value]
System.DateTime.Add(Double value, Int32 scale) +9388319
System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +8837703
System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +125
System.Web.Compilation.BuildManager.CompileCodeDirectories() +319
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +248

[HttpException (0x80004005): Value to add was out of range.
Parameter name: value]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +62
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +421
System.Web.Compilation.BuildManager.CallAppInitializeMethod() +31
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +605

[HttpException (0x80004005): Value to add was out of range.
Parameter name: value]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9013676
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

enter image description here

最佳答案

只是猜测:由于异常似乎是从您无法控制的代码中抛出的,因此导致错误的不是您的代码。但是,这可能是您的系统设置。例如,由于某些奇怪的原因 System.DateTime.Add(Double value, Int32 scale) 被调用时带有这样的参数,即 MSDN states ,

The resulting DateTime is less than MinValue or greater than MaxValue.

是否有可能您计算机上的时间现在设置为某个令人难以置信的高值?例如,接近 23:59:59.9999999, December 31, 9999。或者可能是低值,接近于 00:00:00.0000000, January 1, 0001。因此,由于某些原因,编译器选择了当前日期并需要为其添加一些时间跨度,这会导致您的错误。

只是一个大胆的猜测,但也许......

更新

可以找到System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly方法的代码here .代码中有一行

DateTime waitLimit = DateTime.UtcNow.AddMilliseconds(3000); 

那是唯一可能抛出此类异常的地方(如果我正在查看的版本与您的环境相同)。因此,它会为您计算机上设置的奇怪时间投更多票。

关于c# - VS 2010 错误 "Value to add was out of range. Parameter name: value ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6925322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com