dotnet / dotnet/winforms

Improve error message thrown from exception caused by toolbox item to report which item

Open
#10,789 10 comments 3 reactions 1 assignee Claimed by @KlausLoeffelmann View on GitHub
area-VSDesigner
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

### Environment

Version 17.9.0 Preview 5.0
Version 17.10.0 Preview 2.0

### .NET version

6.0

### Did this work in a previous version of Visual Studio and/or previous .NET release?

_No response_

### Issue description

While loading the toolbox in our solution, a toolbox caused an exception in the designer. Seems like the value should have been in '{0}' of the attached diagnostics log from the designer.

### Steps to reproduce

Unknown what toolbox item causes this.

### Diagnostics

```text
fail: Unable to add tool item to the toolbox '{0}'.
System.ArgumentNullException: Value cannot be null.
Parameter name: targetFrameworks
at Microsoft.WinForms.Utilities.Shared.ThrowHelper.ThrowArgumentNullException(String paramName)
at Microsoft.WinForms.Utilities.Desktop.Toolbox.ToolDataObject..ctor(String typeName, Boolean isInternal, AssemblyName assemblyName, String creationToolName, String targetFrameworks)
at Microsoft.WinForms.DesignTools.Client.Toolbox.BaseToolboxItemSource.CreateToolDataObject(AssemblyName assemblyName, AutoToolboxItem item)
at Microsoft.WinForms.DesignTools.Client.Toolbox.BaseToolboxItemSource.d__28.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.d__1.MoveNext()
at Microsoft.WinForms.DesignTools.Client.Toolbox.BaseToolboxItemSource.AddItemsAndSortWithAnyExistingAutoPopItems(String tabName, IEnumerable`1 candidateToolBoxItems)
at Microsoft.WinForms.DesignTools.Client.Toolbox.BaseToolboxItemSource.d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WinForms.DesignTools.Client.Toolbox.BaseToolboxItemSource.d__61.MoveNext()

For information on how to troubleshoot the designer refer to the guide at https://aka.ms/winforms/designer/troubleshooting.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.