Closed kant2002 closed 2 years ago
I can't repro this issue with sample app, please check below gif WinFormsApp30.zip
VS Version 17.3.0 Preview 1.0 .Net Core version:
I have slightly differnet version of .NET SDK 7.0.100-preview.5.22263.22
Also right now I cannot repro exact this issue, but if I
add
<ItemGroup>
<Reference Include="c:\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\System.Windows.Forms.dll" />
<Reference Include="c:\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\System.Windows.Forms.Primitives.dll" />
</ItemGroup>
then build project
open designer then VS restarts
Event viewer shows
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.DotNet.DesignTools.Client.DesignToolsClientException
at Microsoft.DotNet.DesignTools.Client.DesignToolsClient+<SendRequestAsync>d__49`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTask`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].CompleteOnCurrentThread()
at Microsoft.DotNet.DesignTools.Protocol.Endpoints.DesignToolsEndpoints+InputImpl.InputMessage(Microsoft.DotNet.DesignTools.Protocol.SessionId, UInt32, UIntPtr, IntPtr, System.Drawing.Point, System.Windows.Forms.Keys, IntPtr, System.Nullable`1<Boolean>)
at Microsoft.DotNet.DesignTools.Client.Designers.InputShield.ProcessMessage(WindowMessage, System.Drawing.Point, UIntPtr, IntPtr, Boolean)
at Microsoft.DotNet.DesignTools.Client.Designers.InputShield.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)
I suspect this is separate issue, but who knows. I willing to troubleshoot more, if more knobs given to me.
Ooh. I add Verbose logging and Designer did not crash, and just properly log error. but I see other interesting bits
Notice that stacktrace has a lot of Cursor.ToString
calls which points to potential stack overflow.
[15:26:27.376591] info: [WinFormsApp30]: Added 'System.Reflection'
[15:26:27.376591] info: [WinFormsApp30]: at System.Collections.Hashtable.InitHash(System.Object, Int32, UInt32 ByRef, UInt32 ByRef)
[15:26:27.376591] info: [WinFormsApp30]: at System.Collections.Hashtable.ContainsKey(System.Object)
[15:26:27.376591] info: [WinFormsApp30]: at System.ComponentModel.TypeDescriptor.CheckDefaultProvider(System.Type)
[15:26:27.376591] info: [WinFormsApp30]: at System.ComponentModel.TypeDescriptor.NodeFor(System.Type, Boolean)
[15:26:27.376591] info: [WinFormsApp30]: at System.ComponentModel.TypeDescriptor.GetDescriptor(System.Type, System.String)
[15:26:27.376591] info: [WinFormsApp30]: at System.ComponentModel.TypeDescriptor.GetConverter(System.Type)
[15:26:27.376591] info: [WinFormsApp30]: at System.Windows.Forms.Cursor.ToString()
[15:26:27.376591] info: [WinFormsApp30]: at System.Windows.Forms.CursorConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
[15:26:27.377590] info: [WinFormsApp30]: at System.ComponentModel.TypeConverter.ConvertToString(System.Object)
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.Cursor.ToString()
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.CursorConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
[15:26:27.377590] info: [WinFormsApp30]: at System.ComponentModel.TypeConverter.ConvertToString(System.Object)
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.Cursor.ToString()
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.CursorConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
[15:26:27.377590] info: [WinFormsApp30]: at System.ComponentModel.TypeConverter.ConvertToString(System.Object)
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.Cursor.ToString()
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.CursorConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
[15:26:27.377590] info: [WinFormsApp30]: at System.ComponentModel.TypeConverter.ConvertToString(System.Object)
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.Cursor.ToString()
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.CursorConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
[15:26:27.377590] info: [WinFormsApp30]: at System.ComponentModel.TypeConverter.ConvertToString(System.Object)
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.Cursor.ToString()
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.CursorConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
[15:26:27.377590] info: [WinFormsApp30]: at System.ComponentModel.TypeConverter.ConvertToString(System.Object)
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.Cursor.ToString()
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.CursorConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
[15:26:27.377590] info: [WinFormsApp30]: at System.ComponentModel.TypeConverter.ConvertToString(System.Object)
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.Cursor.ToString()
[15:26:27.377590] info: [WinFormsApp30]: at System.Windows.Forms.CursorConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
[15:26:27.377590] info: [WinFormsApp30]: at System.ComponentModel.TypeConverter.ConvertToString(System.Object)
I would guess that issue here https://github.com/dotnet/winforms/blob/9ea06044776cd10bd1968ee141449bed1a8e6945/src/System.Windows.Forms/src/System/Windows/Forms/CursorConverter.cs#L88
This condition is false when Cursor comes from assembly with different identity(unsure). Because .NET can treat this is as different Cursor classes, it falls down to https://github.com/dotnet/winforms/blob/9ea06044776cd10bd1968ee141449bed1a8e6945/src/System.Windows.Forms/src/System/Windows/Forms/CursorConverter.cs#L146
which just calls object.ToString()
.
- add
<ItemGroup> <Reference Include="c:\winforms\artifacts\bin\System.Windows.Forms\Debug\net7.0\System.Windows.Forms.dll" /> <Reference Include="c:\winforms\artifacts\bin\System.Windows.Forms.Primitives\Debug\net7.0\System.Windows.Forms.Primitives.dll" /> </ItemGroup>
This isn't a supported use case, so we can't really offer much help. I can sort of see how the SDK and VS can get confused here. If you wish to test the latest Windows Forms runtime with the designer you'd need to copy the changes to the SDK. I've written a script for this https://gist.github.com/RussKie/bb11e213f04729603e533856865922c1.
Feel free to reopen if you see the issue in an app without referencing the canary bits.
Environment
Version 17.3.0 Preview 1.0
.NET version
net7.0
Did this work in a previous version of Visual Studio and/or previous .NET release?
No response
Issue description
Seeing
Steps to reproduce
Take sample app from https://github.com/dotnet/winforms/issues/6952 and open in the designer.
Diagnostics
No response