【发布时间】:2021-07-19 12:46:12
【问题描述】:
我已经针对 .Net 6 编译了一个可靠/稳定的解决方案,它编译正常,没有错误也没有警告,我可以操纵主窗体的设计器部分,但是当我启动它时,我收到:
CoreCLR Version: 6.0.21.35212
.NET Version: 6.0.0-preview.6.21352.12
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DivideByZeroException: Attempted to divide by zero.
at System.Math.DivRem(Int64 a, Int64 b, Int64& result) in System.Private.CoreLib.dll:token 0x600046a+0x0
at System.Drawing.ImageAnimator.ImageInfo.AdvanceAnimationBy(Int64 milliseconds) in System.Drawing.Common.dll:token 0x6000bed+0x31
at System.Drawing.ImageAnimator.AnimateImages() in System.Drawing.Common.dll:token 0x60002e0+0x3d
at System.Threading.Thread.StartHelper.Callback(Object state) in System.Private.CoreLib.dll:token 0x600288d+0x0
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in System.Private.CoreLib.dll:token 0x6002a2d+0x40
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in System.Private.CoreLib.dll:token 0x6002a2d+0x80
at System.Threading.Thread.StartCallback() in System.Private.CoreLib.dll:token 0x600280f+0xe
我在代码中没有任何“划分”,我无法调试,因为错误似乎是 dotnet 类的一部分。
你能帮我解决这个问题吗?我只是想预测从 .Net Core 5 到 .Net Core 6 的移植。
【问题讨论】:
-
删除动画图像或替换为静态代理(ImageAnimator 类已被稍微编辑,固定时间范围有所减少,
TotalAnimationTime属性值以不同方式重新计算。此属性由于某种原因,似乎设置为0)。 -- 请注意,您没有最新的预览版。 -
我使用 7 月 14 日的 .Net Core 6 Preview 6,我不使用或引用 ImageAnimator 类。谢谢你,顺便说一句。
-
您不需要添加对
ImageAnimator的引用。所有可以显示动画图像的控件(例如 PictureBox、Button、Label)都使用该类。 -
谢谢!您的评论有助于解决问题:使用动画图像的外部控件。
-
只是一个简短的说明,为什么这个问题应该被评估为 - 1?如果这个网站不是用来问的......对我来说,知道核心 6 中的动画 gif 会导致除以零并且使用调试器,即使取消选中“只是我的代码”,这并不是一件容易的事抓住源头……
标签: winforms .net-core .net-6.0