Improve error message thrown from exception caused by toolbox item to report which item
- 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
Assessment
This issue has not been assessed yet.