Skip to content

[dotnet-sdk-10.0.100-preview.6.25306.101] WPF Apps failed to open the TaskDialog window due to System.ArgumentException: Value does not fall within the expected range #116475

Closed
@Junjun-zhao

Description

@Junjun-zhao

Description

When running against the 3rd party applications with dotnet-sdk-10.0.100-preview.6.25306.101, some WPF applications open TaskDialog window failed with below error message:
System.ArgumentException: Value does not fall within the expected range.

Reproduction Steps

Minimal Repro steps (Demo attached:TaskDialogDemo.zip):

The machine has 10.0.100-preview.6.25306.101 installed.

  1. Create a default 9.0 WPF project.
  2. Install Ookii.Dialogs.Wpf nuget package for the project.
  3. Add below code in MainWindow.xaml.cs file (Please keep only these 2 namespaces):
    using Ookii.Dialogs.Wpf;
    using System.Windows;
    
    namespace ConfirmDialogDemo
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
    
                var dialog = new TaskDialog
                {
                    Content = "message"
                };
                var yesButton = new TaskDialogButton("Yes");
                dialog.Buttons.Add(yesButton);
                var result = dialog.ShowDialog();
            }
        }
    }
    
  4. Build the project.
  5. Update the runtime.config to let the project run against with dotnet-sdk-10.0.100-preview.6.25306.101:
    {
       "runtimeOptions": {
         "tfm": "net9.0",
         "frameworks": [
           {
             "name": "Microsoft.NETCore.App",
             "version": "10.0.0-preview.6.25306.101"
           },
           {
             "name": "Microsoft.WindowsDesktop.App",
             "version": "10.0.0-preview.6.25306.101"
           }
         ],
         "configProperties": {
           "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
           "CSWINRT_USE_WINDOWS_UI_XAML_PROJECTIONS": false
         }
       }
     }
    
  6. Press F5 to run the application.

Expected behavior

App launch successfully with a pop-up dialog shows before the main window load.

Image

Actual behavior

App launch failed with System.ArgumentException: 'Value does not fall within the expected range.'

Stack Trace:

   at Ookii.Dialogs.Wpf.NativeMethods.TaskDialogIndirect(TASKDIALOGCONFIG& pTaskConfig, Int32& pnButton, Int32& pnRadioButton, Boolean& pfVerificationFlagChecked)
   at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog(IntPtr owner)
   at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog(Window owner)
   at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog()
   at ConfirmDialogDemo.MainWindow..ctor() in F:\Demos\ConfirmDialogDemo\ConfirmDialogDemo\MainWindow.xaml.cs:line 24
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

Regression?

Yes

Verify Scenarios:

  1. Windows 10 22H2 + dotnet-sdk-9.0.300: Pass
  2. Windows 10 22H2 + dotnet-sdk-10.0.100-preview.5.25277.114: Pass
  3. Windows 10 22H2 + dotnet-sdk-10.0.100-preview.6.25306.101: Fail

Known Workarounds

No response

Impact

Application crashes when the taskdialog window pop-up.

Configuration

Application Name: NuGetPackageExplorer, RMMVCookTool, AMDownloader, Autodesk Revit 2025
OS: Windows 10 22H2
CPU: X64
.NET Build Number: 10.0.100-preview.6.25306.101
App & App Source Location checking at:
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2499151

Github Link:
https://github.com/NuGetPackageExplorer/NuGetPackageExplorer
https://github.com/acemod13/RMMVCookTool
https://github.com/antikmozib/AM-Downloader

Other information

App Repro steps

The machine has dotnet-sdk-10.0.100-preview.6.25306.101 installed.

  1. Copy AM-Downloader app from SourceShare\ConfirmDialogIssueApps\Apps to local machine.
  2. Update the runtime.config to let the project run against with dotnet-sdk-10.0.100-preview.6.25306.101:
       {
              "runtimeOptions": {
                "tfm": "net8.0",
                "frameworks": [
                  {
                    "name": "Microsoft.NETCore.App",
                    "version": "10.0.0-preview.6.25306.101"
                  },
                  {
                    "name": "Microsoft.WindowsDesktop.App",
                    "version": "10.0.0-preview.6.25306.101"
                  }
                ],
                "configProperties": {
                  "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true,
                  "CSWINRT_USE_WINDOWS_UI_XAML_PROJECTIONS": false
                }
              }
      }
    
  3. Launch AM Downloader.exe.
  4. Click Help -> About menu.

Expected Result:
The About pop-up window will appear.

Image

Actual Result:
The application crashes and get below error from Event View:

Application: AM Downloader.exe
CoreCLR Version: 10.0.25.30701
.NET Version: 10.0.0-preview.6.25306.101
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException: Value does not fall within the expected range.
   at Ookii.Dialogs.Wpf.NativeMethods.TaskDialogIndirect(TASKDIALOGCONFIG& pTaskConfig, Int32& pnButton, Int32& pnRadioButton, Boolean& pfVerificationFlagChecked)
   at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog(IntPtr owner) in F:\Demos\ookii-dialogs-wpf\src\Ookii.Dialogs.Wpf\TaskDialog.cs:line 1147
   at Ookii.Dialogs.Wpf.TaskDialog.ShowDialog(Window owner) in F:\Demos\ookii-dialogs-wpf\src\Ookii.Dialogs.Wpf\TaskDialog.cs:line 1095
   at AMDownloader.Views.MainView.AboutMenu_Click(Object sender, RoutedEventArgs e) in AM Downloader\Views\MainView.xaml.cs:line 213
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at AMDownloader.App.Main()

Findings:
Except Autodesk Revit 2025, other 3 WPF applications are referencing Ookii.Dialogs.Wpf nuget package and issue occurs when calling TaskDialog.ShowDialog() method from the package.
After debugging into the source code of Ookii.Dialogs.Wpf nuget package, we find the issue occurs when calling TaskDialogIndirect() method, which is imported from comctl32.dll. (in "ookii-dialogs-wpf\src\Ookii.Dialogs.Wpf\NativeMethods.cs" file)

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist"), DllImport("comctl32.dll", PreserveSig = false)]
public static extern void TaskDialogIndirect([In] ref TASKDIALOGCONFIG pTaskConfig, out int pnButton, out int pnRadioButton, [MarshalAs(UnmanagedType.Bool)] out bool pfVerificationFlagChecked);

For Autodesk Revit 2025, it also shows the exception is related to TaskDialog in the application log (Full log file attached: journal.0001.txt):

'DefaultButton : Close
  'C 10-Jun-2025 05:37:10.118;  DBG_WARN: TaskDialog Exception:
  'Value does not fall within the expected range.: line 92 of F:\Ship25.4\2025_px64\Source\UIFramework\UIFrameworkInterop\TaskDialog\AdWindowsTaskDialog.cpp.
  'C 10-Jun-2025 05:37:10.121;  DBG_WARN: TaskDialogResult should always be a positive number: line 270 of F:\Ship25.4\2025_px64\Source\UIFramework\UIFrameworkInterop\TaskDialog\AdWindowsTaskDialog.cpp.
'C 10-Jun-2025 05:37:10.121;   0:< Process result of DebugModes-Changed Task Dialog

@dotnet-actwx-bot @dotnet/compat

Metadata

Metadata

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions