Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count down makes exception #14

Open
FaltoGH opened this issue Nov 1, 2023 · 4 comments
Open

Count down makes exception #14

FaltoGH opened this issue Nov 1, 2023 · 4 comments

Comments

@FaltoGH
Copy link

FaltoGH commented Nov 1, 2023

When I set showCountDown true, an exception occurs.

code:

using System.Globalization;
using System.Windows.Forms;

namespace AutoClosingMessageBoxTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            CultureInfo.CurrentUICulture = new CultureInfo("en-US");
            AutoClosingMessageBox.Show(null, showCountDown:true);
        }
    }
}

output:

Unhandled Exception: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
   at System.Text.StringBuilder.ToString(Int32 startIndex, Int32 length)
   at Utils.Win32Api.GetDlgButtonText(IntPtr hWnd, Int32 dlgButtonId)
   at System.Windows.Forms.AutoClosingMessageBox.CountDownStrategy.Proceed()
   at System.Windows.Forms.AutoClosingMessageBox.OnCountDownTimer(Object state)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback(Int32 id)

The snapshot before process is killed.
image

I'm using Windows 10 and Windows display language is Korean.

@DmitryGaravsky
Copy link
Owner

Hi!
The behavior you described definitely looks like a "bug". So I'll try to take a look...
Thanks for you collaboration.

@DmitryGaravsky
Copy link
Owner

DmitryGaravsky commented Sep 28, 2024

Hi! Hope you're doing well.
I tried to reproduce the problem locally but all my attempts were unsuccessful. However, in version 1.0.0.6, I have added additional checks to the code, which may help improve stability. Related change: GetDlgButtonText: some validation added

Please try the updated version and let me know if the issue persists.

@FaltoGH
Copy link
Author

FaltoGH commented Sep 28, 2024

Thank you for your interest.

Since original post was posted in 10 months ago, I hardly remember my environment at that time, but probably I used .NET Framework 4.8 WinForms.

Now I tried to test the issue in .NET Framework 4.8 WinForms and it seems like version 1.0.0.6 does not support .NET Framework 4.8.

The following warning is displaying in Visual Studio:

Found conflicts between different versions of "System.Windows.Forms" that could not be resolved.
There was a conflict between "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
    "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was not.
    References which depend on "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.dll].
        C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.dll
          Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Windows.Forms.dll".
            System.Windows.Forms
    References which depend on or have been unified to "System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [].
        C:\Users\nasoo\source\repos\tmp\packages\AutoClosingMessageBox.1.0.0.6\lib\net472\AutoClosingMessageBox.dll
          Project file item includes which caused reference "C:\Users\nasoo\source\repos\tmp\packages\AutoClosingMessageBox.1.0.0.6\lib\net472\AutoClosingMessageBox.dll".
            AutoClosingMessageBox, Version=1.0.0.6, Culture=neutral, processorArchitecture=MSIL

And when I try to execute the code that shows auto closing message box, the following exception is thrown:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Well, I have already implemented my own auto closing message box by myself, a long time ago.
If supporting .NET Framework 4.8 WinForms is not intended, you don't have to worry.

Thanks

@DmitryGaravsky
Copy link
Owner

Oops! I checked the resulting NuGet package using NuGet Package Explorer and noticed that the .NET Framework DLL was unexpectedly replaced with the one for .NET 8.
image
I'm not sure why this happened, but I’ll do my best to fix it as soon as possible. Thank you for your prompt response, and I apologize for the inconvenience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants