winforms icon indicating copy to clipboard operation
winforms copied to clipboard

VS 2026: Winforms designer (net9) doesn't release bin dll on rebuild

Open AdmiralSnyder opened this issue 2 months ago • 5 comments

Environment

VS Version: Insiders [11111.16]

.NET version

.net core 9

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

i don't remember having these problems last time i touched this project in VS2022 about a year ago, but i'm not sure there.

Issue description

when designing a component the out-of-process winforms designer opens and locks the dll file the component's base type is in. but sadly, it doesn't release that assembly on build. so i cannot compile because i get lots of these errors:

1>C:\Program Files\Microsoft Visual Studio\18\Insiders\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4903,5): warning MSB3026: Could not copy "obj\Debug\net9.0\Bipro_V2_9_3.dll" to "bin\Debug\net9.0\Bipro_V2_9_3.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'bin\Debug\net9.0\Bipro_V2_9_3.dll' because it is being used by another process. The file is locked by: "DesignToolsServer (21796)"

this only goes away when closing and reopening VS (i didn't dare to kill the DesignToolsServer process alone, yet)

this hurts when using visual inheritance This needs to be fixed before VS2026 RTMs, or you get soooo many error tickets.

Steps to reproduce

create a .net 9 winforms app create a usercontrol A create a usercontrol B deriving from it open UserControl A in the designer, modify it and save open usercontorl B in the designer, modify it try to rebuild.

Diagnostics

1>C:\Program Files\Microsoft Visual Studio\18\Insiders\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4903,5): warning MSB3026: Could not copy "obj\Debug\net9.0\Bipro_V2_9_3.dll" to "bin\Debug\net9.0\Bipro_V2_9_3.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'bin\Debug\net9.0\Bipro_V2_9_3.dll' because it is being used by another process. The file is locked by: "DesignToolsServer (21796)"

AdmiralSnyder avatar Oct 20 '25 12:10 AdmiralSnyder

There is an existing internal WinForms designer issue (https://github.com/microsoft/winforms-designer/issues/6477 ). We’ll update once the issue is resolved.

Olina-Zhang avatar Oct 21 '25 03:10 Olina-Zhang

We are working towards a fix currently!

merriemcgaw avatar Oct 22 '25 20:10 merriemcgaw

I am probably facing the same issue in Visual Studio 2026 [11116.177]
When a CustomControl is defined in a class library project and then the CustomControl is used in a Winforms application project in the same solution, the solution can't be rebuilt, as long as a Winforms designer tab is opened in Visual Studio. Both projects have .NET 8 as their target framework. The DesignToolsServer.exe process has the DLL file of the class library locked and therefore it can't be replaced by the MSBuild process.
This whole setup works flawlessly with no errors in Visual Studio 2022 [17.14.18]

Muckenbatscher avatar Oct 23 '25 11:10 Muckenbatscher

Hi all.

Thank you for bringing this to our attention. We are working on a fix that should be out by the time we go to GA. We will let you know if that does not occur, but it's looking very good.

merriemcgaw avatar Oct 27 '25 17:10 merriemcgaw

This seems to be resolved in VS 2026 Update 11201.2 I could not reproduce the locking error in that version.

Muckenbatscher avatar Nov 04 '25 08:11 Muckenbatscher