.NET Core Version:
.NET 5 Preview 7 and all past .NET versions since 2.0
Have you experienced this same bug with .NET Framework?:
Yes
Problem description:
TabPageCollection.Insert() is supposed to insert a TabPage at the provided index in a TabControl. However, for a _very_ long time, there has been a bug that prevents it from working unless you force the creation of the TabControl.Handle before attempting, like so:
IntPtr h = tabControl1.Handle;
This was pointed out as the undocumented answer to this same bug being posted about on msdn in 2005 and continues to behave this way in .NET 5.
I believe the underlying issue is that the TabControl handle is not properly created in some situations but I don't know how that works under the hood.
NOTE: I have been able to use Insert() inside of an event handler of a TabControl, presumably at the point the handle already exists.
Expected behavior:
TabPages should be able to be inserted into TabControls without forcing handle creation.
Minimal repro:
public partial class Form1 : Form
{
private TabControl TabControl { get; set; }
public Form1()
{
InitializeComponent();
}
public void InitializeComponent()
{
TabControl = new TabControl();
var page1 = new TabPage();
var page2 = new TabPage();
var page3 = new TabPage();
page1.Text = "First works";
TabControl.TabPages.Add(page1);
page2.Text = "Second fails";
TabControl.TabPages.Insert(1, page2);
IntPtr h = TabControl.Handle;
page3.Text = "Third works";
TabControl.TabPages.Insert(1, page3);
Controls.Add(TabControl);
}
}
Resulting window:

Some kind of feedback would be appreciated.
This issue is on the backlog. You鈥檙e welcome to send a PR with a fix.
Thanks!
I would gladly take this issue. Is it possible that you assign it to me ?
All yours :)
Holler if you get stuck
@RussKie I got stuck before I could start :) I can't seem to compile the source code. I have vs2019 with required workloads (c# desktop, c++) installed. Also installed Cmake. Here is the output of the build.cmd file:
**********************************************************************
** Visual Studio 2019 Developer PowerShell v16.7.3
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
PS E:\Hacktoberfest\winforms> .\build.cmd
Processing E:\Hacktoberfest\winforms\global.json
cmake.exe already exists; replacing...
dotnet-api-docs_netcoreapp3.0 was not found in .
Native tools bootstrap failed
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.6.20310.4/dotnet-sdk-5.0.100-preview.6.20310.4-win-x64.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.6.20310.4/dotnet-sdk-5.0.100-preview.6.20310.4-win-x64.zip
dotnet-install: Adding to current process PATH: "E:\Hacktoberfest\winforms\.dotnet\". Note: This change will not be visible if PowerShell was run as a child process.
dotnet-install: Installation finished
E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\MSBuild.dll /nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\dotnet.dll -maxcpucount /m -verbosity:m /v:minimal /bl:E:\Hacktoberfest\winforms\artifacts\log\Debug\ToolsetRestore.binlog /clp:Summary /clp:ErrorsOnly;NoSummary /nr:True /p:ContinuousIntegrationBuild=False /p:TreatWarningsAsErrors=true /p:__ToolsetLocationOutputFile=E:\Hacktoberfest\winforms\artifacts\toolset\5.0.0-beta.20465.7.txt /t:__WriteToolsetLocation /warnaserror E:\Hacktoberfest\winforms\artifacts\toolset\restore.proj
E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\MSBuild.dll /nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\dotnet.dll -maxcpucount /m -verbosity:m /v:minimal /bl:E:\Hacktoberfest\winforms\artifacts\log\Debug\Build.binlog /clp:Summary /nr:True /p:ContinuousIntegrationBuild=False /p:TreatWarningsAsErrors=true /p:Configuration=Debug /p:RepoRoot=E:\Hacktoberfest\winforms /p:Restore=True /p:DeployDeps=False /p:Build=True /p:Rebuild=False /p:Deploy=False /p:Test=False /p:Pack=False /p:IntegrationTest=False /p:PerformanceTest=False /p:Sign=False /p:Publish=False /warnaserror F:\nuget-packages\microsoft.dotnet.arcade.sdk\5.0.0-beta.20465.7\tools\Build.proj
Determining projects to restore...
Restored F:\nuget-packages\microsoft.dotnet.arcade.sdk\5.0.0-beta.20465.7\tools\Tools.proj (in 131 ms).
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-alpha.1.20468.7/dotnet-runtime-6.0.0-alpha.1.20468.7-win-x64.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-alpha.1.20468.7/dotnet-runtime-6.0.0-alpha.1.20468.7-win-x64.zip
dotnet-install: Installation finished
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-alpha.1.20468.7/dotnet-runtime-6.0.0-alpha.1.20468.7-win-x86.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-alpha.1.20468.7/dotnet-runtime-6.0.0-alpha.1.20468.7-win-x86.zip
dotnet-install: Adding to current process PATH: "E:\Hacktoberfest\winforms\.dotnet\x86\". Note: This change will not be visible if PowerShell was run as a child process.
dotnet-install: Installation finished
Determining projects to restore...
Determining projects to restore...
Restored E:\Hacktoberfest\winforms\src\System.Windows.Forms\tests\InteropTests\NativeTests\NativeTests.proj (in 5.92 sec).
Restored E:\Hacktoberfest\winforms\pkg\Microsoft.Dotnet.WinForms.ProjectTemplates\Microsoft.Dotnet.Winforms.ProjectTemplates.csproj (in 69 ms).
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/runtime.win-x64.microsoft.netcore.ilasm/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.dotnet.xunitextensions/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/newtonsoft.json/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/a8a526e9-91b3-4569-ba2d-ff08dbb7c110/nuget/v3/flat2/system.drawing.common/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/system.runtime.compilerservices.unsafe/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/runtime.win-x64.microsoft.netcore.ilasm/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.net.test.sdk/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/a8a526e9-91b3-4569-ba2d-ff08dbb7c110/nuget/v3/flat2/system.codedom/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/microsoft.net.test.sdk/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/xunit.stafact/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/moq/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/825db618-e3eb-4426-ba54-b1d6e6c944d8/nuget/v3/flat2/system.codedom/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/system.windows.extensions/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/microsoft.net.test.sdk/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.dotnet.remoteexecutor/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/system.drawing.common/index.json'.
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.win32.registry/index.json'.
......
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/system.xml.xmldocument/index.json'.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/flat2/system.componentmodel/index.json'.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/flat2/system.xml.xmldocument/index.json'.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\NuGet.targets(128,5): error : Failed to retrieve information about 'Microsoft.DotNet.XUnitExtensions' from remote source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.dotnet.xunitextensions/index.json'. [E:\Hacktoberfest\winforms\Winforms.sln]
E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\NuGet.targets(128,5): error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [E:\Hacktoberfest\winforms\Winforms.sln]
Build FAILED.
E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\NuGet.targets(128,5): error : Failed to retrieve information about 'Microsoft.DotNet.XUnitExtensions' from remote source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/microsoft.dotnet.xunitextensions/index.json'. [E:\Hacktoberfest\winforms\Winforms.sln]
E:\Hacktoberfest\winforms\.dotnet\sdk\5.0.100-preview.6.20310.4\NuGet.targets(128,5): error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [E:\Hacktoberfest\winforms\Winforms.sln]
0 Warning(s)
1 Error(s)
Time Elapsed 00:01:31.92
Build failed.
See log: E:\Hacktoberfest\winforms\artifacts\log\Debug\Build.binlog
@yvz5 are you behind any kind of firewall that would block https://pkgs.dev.azure.com? Is that an alternate URL to the default nuget location?
EDIT: I get a PackageNotFoundException when I browse to any of those URLs, so probably not a firewall thing. Did you change the Nuget source?
I havent changed any settings. Here is my nuget.config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<clear />
<add key="globalPackagesFolder" value="C:\Users\yvz5\.nuget" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
May be a setting that came with the repo then. I won't be able to help as I'm not super familiar with the repo. @RussKie ?
I've cloned and restored the solution on my personal laptop (which isn't connected to the corp network in anyway) without issues:
C:\Development\winforms>Restore.cmd
Processing C:\Development\winforms\global.json
cmake.exe already exists; replacing...
dotnet-api-docs_netcoreapp3.0 was not found in .
Native tools bootstrap failed
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.6.20310.4/dotnet-sdk-5.0.100-preview.6.20310.4-win-x64.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.6.20310.4/dotnet-sdk-5.0.100-preview.6.20310.4-win-x64.zip
dotnet-install: Adding to current process PATH: "C:\Development\winforms\.dotnet\". Note: This change will not be visible if PowerShell was run as a child process.
dotnet-install: Installation finished
Determining projects to restore...
Restored C:\Users\russkie\.nuget\packages\microsoft.dotnet.arcade.sdk\5.0.0-beta.20465.7\tools\Tools.proj (in 7.6 sec).
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-alpha.1.20468.7/dotnet-runtime-6.0.0-alpha.1.20468.7-win-x64.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-alpha.1.20468.7/dotnet-runtime-6.0.0-alpha.1.20468.7-win-x64.zip
dotnet-install: Installation finished
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-alpha.1.20468.7/dotnet-runtime-6.0.0-alpha.1.20468.7-win-x86.zip
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.0-alpha.1.20468.7/dotnet-runtime-6.0.0-alpha.1.20468.7-win-x86.zip
dotnet-install: Adding to current process PATH: "C:\Development\winforms\.dotnet\x86\". Note: This change will not be visible if PowerShell was run as a child process.
dotnet-install: Installation finished
Determining projects to restore...
Determining projects to restore...
Restored C:\Development\winforms\src\System.Windows.Forms\tests\InteropTests\NativeTests\NativeTests.proj (in 15.83 sec).
Restored C:\Development\winforms\src\Microsoft.VisualBasic\tests\UnitTests\Microsoft.VisualBasic.Tests.csproj (in 14.43 sec).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\MauiTests\MauiListViewTests\MauiListViewTests.csproj (in 15.96 sec).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\MauiTests\MauiComboBoxTests\MauiComboBoxTests.csproj (in 15.96 sec).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\MauiTests\MauiLabelTests\MauiLabelTests.csproj (in 15.96 sec).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\MauiTests\MauiButtonTests\MauiButtonTests.csproj (in 1.47 sec).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\AccessibilityTests\AccessibilityTests.csproj (in 18 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\src\System.Windows.Forms.csproj (in 151 ms).
Restored C:\Development\winforms\src\System.Windows.Forms.Primitives\tests\TestUtilities\System.Windows.Forms.Primitives.TestUtilities.csproj (in 140 ms).
Restored C:\Development\winforms\src\System.Windows.Forms.Primitives\tests\UnitTests\System.Windows.Forms.Primitives.Tests.csproj (in 160 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\InteropTests\System.Windows.Forms.Interop.Tests.csproj (in 99 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\System.Windows.Forms.Maui.IntegrationTests\System.Windows.Forms.Maui.IntegrationTests.csproj (in 110 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\TestUtilities\System.Windows.Forms.TestUtilities.csproj (in 2.47 sec).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\System.Windows.Forms.IntegrationTests.Common\System.Windows.Forms.IntegrationTests.Common.csproj (in 39 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\MauiTests\MauiToolStripTests\MauiToolStripTests.csproj (in 82 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\MauiTests\MauiTestsHelper\MauiTestsHelper.csproj (in 36 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\MauiTests\MauiPropertyGridViewTests\MauiPropertyGridViewTests.csproj (in 40 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\MauiTests\MauiMonthCalendarTests\MauiMonthCalendarTests.csproj (in 105 ms).
Restored C:\Development\winforms\src\System.Windows.Forms.Primitives\src\System.Windows.Forms.Primitives.csproj (in 22 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\WinformsControlsTest\WinformsControlsTest.csproj (in 3.29 sec).
Restored C:\Development\winforms\src\System.Windows.Forms.Design\tests\UnitTests\System.Windows.Forms.Design.Tests.csproj (in 208 ms).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\UnitTests\System.Windows.Forms.Tests.csproj (in 3.45 sec).
Restored C:\Development\winforms\src\System.Windows.Forms\tests\IntegrationTests\System.Windows.Forms.IntegrationTests\System.Windows.Forms.IntegrationTests.csproj (in 2.91 sec).
Restored C:\Development\winforms\src\System.Windows.Forms.Design\src\System.Windows.Forms.Design.csproj (in 99 ms).
Restored C:\Development\winforms\src\System.Windows.Forms.Design.Editors\src\System.Windows.Forms.Design.Editors.Facade3x.csproj (in 14.51 sec).
Restored C:\Development\winforms\src\System.Drawing\src\System.Drawing.Facade.csproj (in 14.53 sec).
Restored C:\Development\winforms\src\System.Design\src\System.Design.Facade.csproj (in 14.48 sec).
Restored C:\Development\winforms\src\System.Drawing.Design\src\System.Drawing.Design.Facade.csproj (in 14.52 sec).
Restored C:\Development\winforms\src\Microsoft.VisualBasic\tests\IntegrationTests\VisualBasicRuntimeTest\VisualBasicRuntimeTest.csproj (in 13 ms).
Restored C:\Development\winforms\src\Microsoft.VisualBasic\src\Microsoft.VisualBasic.Facade.csproj (in 51 ms).
Restored C:\Development\winforms\src\Microsoft.VisualBasic.Forms\src\Microsoft.VisualBasic.Forms.vbproj (in 11 ms).
Restored C:\Development\winforms\src\Accessibility\ver\Accessibility-version.csproj (in 13 ms).
Restored C:\Development\winforms\src\Microsoft.VisualBasic\tests\IntegrationTests\Microsoft.VisualBasic.IntegrationTests\Microsoft.VisualBasic.IntegrationTests.csproj (in 87 ms).
Restored C:\Development\winforms\pkg\Microsoft.Dotnet.WinForms.ProjectTemplates\Microsoft.Dotnet.Winforms.ProjectTemplates.csproj (in 9 ms).
Restored C:\Development\winforms\pkg\Microsoft.Private.Winforms\Microsoft.Private.Winforms.csproj (in 9 ms).
Restored C:\Development\winforms\src\Accessibility\src\Accessibility.ilproj (in 3.09 sec).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:01:56.24
From your logs this looks like the issue:
The SSL connection could not be established, see inner exception.
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I don't what exactly is causing it, a quick search suggests this may be to do with SSL certs in our auth chain. This may happen in corporate environments, or if you behind a proxy...
So I checked my network and found nothing blocking the url. I dont have firewall nor proxy. I am able to download public nuget packages. I am also able to call curl with https endpoints.
Then I tried building on a freshly installed pc and it worked. Same network, different machines. Anyway, I will work on this new machine :) @RussKie Thanks for your time.
@yvz5 have you given up? :(
@cbrit Unfortunately I don't have enough time to invest in learning the code base.
@RussKie I can't work on this anymore, sorry about that.
You are correct @cbrit there is an issue with the TabControl handle during Insert. In this case there is a check for if (IsHandleCreated) before performing the insert and the handle does not appear to be created, so the insert does not occur.
I can see 2 other methods in TabControl where a handle is created by calling CreateHandle(), which in my testing, appears to alleviate the issue described here.
Can someone with more knowledge comment on whether or not creating the handle in this situation would be an acceptable solution?
No, implicit handle creation is dangerous, and more often wrong than not. The WinForms codebase had to fix plenty of bugs of this type in their unit tests by _preventing_ implicit handling creation. Introducing additional places with implicit handle creation very likely will introduce new bugs, not only in the unit tests but also in external code.
The original issue description correctly states that it should be possible for the TabControl to model the tab pages without forcing handle creation, doing what you suggest is working around the bug instead of fixing it (i.e. the internal model of the tab pages is still nonfunctional without handle created). Considering that this bug has been around so long lets take the time to properly analyze and fix it, not just commit to some workaround, unless it has been determined to be the only viable solution.
ImageList for example is able to model its picture list without the handle being created, TabControl should not be any different, it should just maintain a collection of pages and then use it to initialize the native control when the time comes to do so. (Disclaimer: I didn't read through the source or analyze the bug, this is just the high level understanding, there may be low level issues preventing things to work this way, but so far I see nothing mentioned here.)
Thank you for the thorough reply.
Considering that this bug has been around so long lets take the time to properly analyze and fix it, not just commit to some workaround, unless it has been determined to be the only viable solution.
I haven't proposed that we commit to anything yet, just thinking out loud.
TabControl Insert is currently checking for if the handle is created before performing the insert. If I remove the check for if the handle is created, the insert appears to work but then I'm seeing additional tests that fail that are perhaps expecting the current behavior. I'll take a closer look at this today and see if I can learn anything new. I'm sure I will have more questions.
From what I can tell its simply missing an else-branch for the "IsHandleCreated" check which updates the _tabPages array. It probably can just call Insert like in the if-branch. Shouldn't need any handle or SendMessage call.
If I have it call Insert like in the if-branch without the handle or SendMessage call, I get 13 test failures in System.Windows.Forms.Tests.TabControlTabPageCollectionTests. Looking into those failing tests now to see what they are expecting.
If you open a draft PR it would be easier to discuss the approach, and reason about the test failures 馃槈
Most helpful comment
If you open a draft PR it would be easier to discuss the approach, and reason about the test failures 馃槈