{"id":248136,"date":"2024-02-29T11:57:04","date_gmt":"2024-02-29T19:57:04","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=248136"},"modified":"2024-03-01T14:31:40","modified_gmt":"2024-03-01T22:31:40","slug":"winforms-designer-selection-for-32-bit-net-framework-projects","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/winforms-designer-selection-for-32-bit-net-framework-projects\/","title":{"rendered":"WinForms Designer Selection for 32-bit .NET Framework Projects\u00a0"},"content":{"rendered":"<p><img decoding=\"async\" width=\"1413\" height=\"400\" class=\"wp-image-248137\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-windows-form-contained-in-a-32-bit-net.png\" alt=\"Image of a Windows Form contained in a 32-bit .NET Framework project. The Form is utilizing Windows Forms out-of-process designer. \" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-windows-form-contained-in-a-32-bit-net.png 1413w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-windows-form-contained-in-a-32-bit-net-300x85.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-windows-form-contained-in-a-32-bit-net-1024x290.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-windows-form-contained-in-a-32-bit-net-768x217.png 768w\" sizes=\"(max-width: 1413px) 100vw, 1413px\" \/><\/p>\n<p>Visual Studio 2022\u2019s transition to a 64-bit architecture, driven by customer feedback across the full range of Visual Studio developers, marked a pivotal step towards enhancing the development experience. As Klaus Loffelmann describes in his <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/winforms-designer-64-bit-path-forward\/\">blog post<\/a>, this transition enhances overall performance and responsiveness, particularly when working with resource-intensive tasks and large codebases. However, this evolution brings with it a notable challenge for some .NET Framework projects using the Windows Forms designer in Visual Studio 2022. The challenge lies in the inability to design Forms in .NET Framework projects that rely on 32-bit references, a consequence of the inherent technical limitation where the 64-bit devenv.exe Visual Studio process cannot load 32-bit compiled references. This specific hurdle has emerged as a significant adoption blocker for users with Windows Forms .NET Framework projects that extensively leverage ActiveX\/COM controls or other custom controls embedded in 32-bit assemblies. Until now, the workaround for such scenarios was to use Visual Studio 2019, where the Windows Forms designer operated as a 32-bit process, accommodating the specific needs of these projects.<\/p>\n<p>Recognizing the limitations imposed by this shift, and its impact on our developers, we have been working hard on features to pave the way for designing legacy WinForms 32-bit .NET Framework applications in the latest Visual Studio environment. While these initial efforts will not comprehensively solve the entire problem space, our aim is to unblock customers and make the transition to a 64-bit Visual Studio 2022 smoother.<\/p>\n<p>In the most recent Visual Studio 2022 release, v17.9, the WinForms team introduced a preview feature &#8211; the <a href=\"https:\/\/learn.microsoft.com\/dotnet\/desktop\/winforms\/controls-design\/designer-differences-framework?view=netdesktop-8.0#out-of-process-designer\" target=\"_blank\" rel=\"noopener\">out-of-process designer<\/a> support for .NET Framework projects. The ability to use our out-of-process designer for .NET Framework is currently in an early preview state, and we eagerly seek developers&#8217; feedback to refine and improve its functionality. Notably, the Visual Studio 17.9 release brought forth crucial enhancements, including:<\/p>\n<ul>\n<li>Improved Type Resolution for .NET Framework projects<\/li>\n<li>ActiveX\/COM support for both .NET Framework and .NET projects<\/li>\n<li>A new Designer Selection Feature to monitor 32-bit assembly load failures in .NET Framework projects<\/li>\n<\/ul>\n<p>These additions signify our commitment to actively engage with the community, understand the intricacies of their projects, and steadily build features that pave the way for the best possible Visual Studio experience. We hope this approach will make it easier for developers to eventually migrate to .NET to gain all the benefits of a more modern platform without a complete rewrite of the user interface.<\/p>\n<h3>What&#8217;s Designer Selection Feature?<\/h3>\n<p>When the WinForms designer detects a 32-bit assembly load failure, it presents the following dialog which provides an option to select appropriate designer for the developer&#8217;s project:<\/p>\n<p><img decoding=\"async\" width=\"1004\" height=\"446\" class=\"wp-image-248138\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/picture-of-a-dialog-asking-do-you-want-to-use-the.png\" alt=\"Picture of a dialog asking &quot;Do you want to use the Windows Forms out-of-process designer for 'WinFormsApp' project?&quot; and Yes\/No buttons, with the option to Get More Info and Remember for current project\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/picture-of-a-dialog-asking-do-you-want-to-use-the.png 1004w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/picture-of-a-dialog-asking-do-you-want-to-use-the-300x133.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/picture-of-a-dialog-asking-do-you-want-to-use-the-768x341.png 768w\" sizes=\"(max-width: 1004px) 100vw, 1004px\" \/><\/p>\n<p>By choosing \u2018Yes,\u2019 the project is reloaded, and the Windows Forms out-of-process designer comes into play. If the project is targeting x86, the designer initiates a 32-bit process to render the Form in the designer. The process is identified as \u2018FxDesignToolsServer.exe.\u2019 Within this process, control assemblies are loaded, and it executes the code in \u2018InitializeComponent\u2019 method aligned with the specified framework.<\/p>\n<p>On selecting \u2018No,\u2019 the project will continue to use in-process designer, although you still won\u2019t be able to design forms referencing 32-bit components simply because 32-bit binaries cannot be loaded in a 64-bit process.<\/p>\n<p>With \u2018Yes\/No\u2019 buttons, the designer selection will remember this setting for the current Visual Studio instance only. To add the designer selection as a project configuration property automatically, enable the option \u2018Remember for current project.\u2019 It will add the \u2018UseWinFormsOutOfProcDesigner\u2019 property to each project configuration. The WinForms Designer will read this property value to select the desired Designer version (In-Process or Out-Of-Process) automatically the next time project is open in Visual Studio. Here is a sample project configuration after adding this property:<\/p>\n<pre class=\"prettyprint language-xml\" style=\"padding-left: 40px;\"><code class=\"language-xml\">&lt;PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \"&gt;\r\n\u00a0\u00a0\u00a0 &lt;PlatformTarget&gt;x86&lt;\/PlatformTarget&gt;\u00a0\r\n\u00a0\u00a0\u00a0 &lt;OutputPath&gt;bin\\Debug\\&lt;\/OutputPath&gt;\r\n    <span style=\"color: #ff0000;\">&lt;UseWinFormsOutOfProcDesigner&gt;True&lt;\/UseWinFormsOutOfProcDesigner&gt;<\/span>\r\n&lt;\/PropertyGroup&gt; <\/code><\/pre>\n<p><code><\/code><\/p>\n<p>Note that the Designer Selection feature is currently under the following preview feature flag which is enabled by default in Visual Studio 2022 17.9:<\/p>\n<p><img decoding=\"async\" width=\"1600\" height=\"170\" class=\"wp-image-248139\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-section-of-the-tools-greateroptions-greaterpreview.png\" alt=\"Image of a section of the Tools-&gt;Options-&gt;Preview features dialog showing the &quot;Detect 32-bit assembly load failures...&quot; option check box\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-section-of-the-tools-greateroptions-greaterpreview.png 1600w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-section-of-the-tools-greateroptions-greaterpreview-300x32.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-section-of-the-tools-greateroptions-greaterpreview-1024x109.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-section-of-the-tools-greateroptions-greaterpreview-768x82.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-a-section-of-the-tools-greateroptions-greaterpreview-1536x163.png 1536w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p>You can enable or disable the feature in Visual Studio under <strong>Tools -&gt; Options -&gt; Preview Features<\/strong>.<\/p>\n<p>The below InfoBar will show up when you use out-of-process designer for .NET Framework projects:<\/p>\n<p><img decoding=\"async\" width=\"1220\" height=\"131\" class=\"wp-image-248140\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-the-visual-studio-infobar-with-the-text.png\" alt=\"Image of the Visual Studio InfoBar with the text &quot;This project is using Windows forms out-of-process designer for .NET Framework projects.&quot; followed by a &quot;Learn More&quot; link.\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-the-visual-studio-infobar-with-the-text.png 1220w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-the-visual-studio-infobar-with-the-text-300x32.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-the-visual-studio-infobar-with-the-text-1024x110.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/02\/image-of-the-visual-studio-infobar-with-the-text-768x82.png 768w\" sizes=\"(max-width: 1220px) 100vw, 1220px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>What this feature does and what it doesn\u2019t do.<\/h3>\n<p><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">In contrast to the in-process designer which loads all assemblies related to third-party controls into the Visual Studio process, the out-of-process designer needs to be pickier; it loads design-time assemblies either into a dedicated server process or into the client Visual Studio process. This distinction in assembly loading is necessary because of the client-server architecture of the out-of-process designer and as a result, third-party control vendors need to use the new <\/span><a style=\"background-color: #f7f7f9; font-size: 1rem; text-align: var(--bs-body-text-align);\" href=\"https:\/\/www.nuget.org\/packages\/Microsoft.WinForms.Designer.SDK\/1.9.0-preview.3.24054.5\" target=\"_blank\" rel=\"noopener\">designer SDK<\/a><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\"> for providing controls for out-of-process designer. Note that creating different design time assemblies for client and server processes is not necessary to support simple scenarios but it is required for more advanced scenarios. Learn more about it <\/span><a style=\"background-color: #f7f7f9; font-size: 1rem; text-align: var(--bs-body-text-align);\" href=\"https:\/\/learn.microsoft.com\/dotnet\/desktop\/winforms\/controls-design\/designer-overview?view=netdesktop-8.0\" target=\"_blank\" rel=\"noopener\">here<\/a><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">. As a result, the out-of-process designer for .NET Framework projects will not be able to handle all third-party controls designed for an in-process design environment. If it encounters such a control, there is a possibility that this will simply omit code related to controls the designer cannot render. Hence, we recommend that you create a backup of your project beforehand.<\/span><\/p>\n<ul>\n<li>Controls referenced in your project will not appear in the Toolbox for use in other forms in the solution, yet. We are aiming to add this ability in one of the upcoming releases.<\/li>\n<li>When loading controls in the out of process designer which have custom CodeDOM serializers, the designer will currently omit the generated code in InitializeComponent (because it cannot run the CodeDOM serializer the way it used to). We hope to add warnings in a future release that will let you know in advance that the project will not be able to load the particular component.<\/li>\n<\/ul>\n<p><strong><em>Side Note:<\/em><\/strong> You may find that there is a significant difference in the code generated in \u2018InitializeComponent\u2019 method in .NET Framework projects that are using the new SDK-style project files as compared to the older legacy csproj files. This is because the out-of-process designer, when it encounters SDK-style projects, utilizes Roslyn behind the scenes for code generation rather than the older CodeModel technology. Learn more about this feature <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/winforms-codegen-update\/\" target=\"_blank\" rel=\"noopener\">here<\/a>. In the long run, this is a big win for your code and supports future multi-targeting and migration paths. There may be minor tweaks in the code generated for those legacy csproj style projects, but these would be much less significant and would work just fine should the same project be opened in VS 2019.<\/p>\n<h3>Roadmap for .NET Framework projects support in the Out-of-Process Designer<\/h3>\n<p>As mentioned earlier in this blog, we plan to add support for the following features in out-of-process designer in upcoming Visual Studio releases:<\/p>\n<ul>\n<li>Enhance Toolbox support for controls referenced in the solution.<\/li>\n<li>More detailed warnings when the designer is unable to load controls with custom CodeDOM Serializers.<\/li>\n<\/ul>\n<h3>What can you do to prepare for a 64-bit world?<\/h3>\n<p>This feature is not intended to make the transition to Visual Studio 2022 action-free on the part of developers of WinForms .NET Framework applications that use legacy 32-bit components in their code. The development landscape has changed dramatically since many of these legacy components were created. Many of them do not meet today\u2019s standards for code-security, for example. The Designer Selection Feature, and the related support for .NET Framework WinForms applications in the out-of-process designer is intended to be a short-term bridge to a final solution for your applications. In the long run, applications that are currently using 32-bit components have two potential options: either upgrade the component to something AnyCPU or 64-bit, or preferably, upgrade your application to .NET 8 and beyond. The .NET 8 platform has full support for 32-bit COM and ActiveX controls in WinForms applications. There is also a robust 3<sup>rd<\/sup> party control vendor ecosystem that is growing every day.<\/p>\n<p>To find out more about the strategy WinForms is taking with 32-bit components, see Klaus Loffelmann and Merrie McGaw\u2019s recent blog: <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/winforms-designer-64-bit-path-forward\/\" target=\"_blank\" rel=\"noopener\">WinForms in a 64-Bit world \u2013 our strategy going forward<\/a>.<\/p>\n<h3>Closing<\/h3>\n<p>We appreciate the time you\u2019ve spent reporting issues\/suggestions and hope you continue to give us feedback when using Visual Studio on what you like and what we can improve. Your feedback is critical to help us make Visual Studio the best tool it can be! You can share feedback with us via\u202f<a href=\"https:\/\/developercommunity.visualstudio.com\/home%22%20\/t%20%22_blank\" target=\"_blank\" rel=\"noopener\">Developer Community<\/a>: report any bugs or issues via\u202f<a href=\"https:\/\/learn.microsoft.com\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio?view=vs-2022\" target=\"_blank\" rel=\"noopener\">report a problem<\/a>\u202fand\u202f<a href=\"https:\/\/developercommunity.microsoft.com\/VisualStudio\/suggest\" target=\"_blank\" rel=\"noopener\">share your suggestions<\/a>\u202ffor new features or improvements to existing ones.<\/p>\n<p>Stay connected with the Visual Studio team by following us on <a href=\"https:\/\/www.youtube.com\/@visualstudio\" target=\"_blank\" rel=\"noopener\">YouTube<\/a>, <a href=\"https:\/\/twitter.com\/VisualStudio\" target=\"_blank\" rel=\"noopener\">Twitter<\/a>, <a href=\"https:\/\/www.linkedin.com\/showcase\/microsoft-visual-studio\/\" target=\"_blank\" rel=\"noopener\">LinkedIn<\/a>, <a href=\"https:\/\/www.twitch.tv\/visualstudio\" target=\"_blank\" rel=\"noopener\">Twitch<\/a> and on <a href=\"https:\/\/learn.microsoft.com\/en-us\/visualstudio\/?view=vs-2022\" target=\"_blank\" rel=\"noopener\">Microsoft Learn<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio 2022\u2019s transition to a 64-bit architecture, driven by customer feedback across the full range of Visual Studio developers, marked a pivotal step towards enhancing the development experience. As Klaus Loffelmann describes in his blog post, this transition enhances overall performance and responsiveness, particularly when working with resource-intensive tasks and large codebases. However, this [&hellip;]<\/p>\n","protected":false},"author":10506,"featured_media":248146,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[1196,155,6930],"tags":[6932,6934,6935,6933,6931,2146],"class_list":["post-248136","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-desktop","category-visual-studio","category-windows-forms","tag-32-bit","tag-designer","tag-designer-selection","tag-out-of-process","tag-windows-forms","tag-winforms","post_format-post-format-image"],"acf":[],"blog_post_summary":"<p>Visual Studio 2022\u2019s transition to a 64-bit architecture, driven by customer feedback across the full range of Visual Studio developers, marked a pivotal step towards enhancing the development experience. As Klaus Loffelmann describes in his blog post, this transition enhances overall performance and responsiveness, particularly when working with resource-intensive tasks and large codebases. However, this [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/248136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/10506"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=248136"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/248136\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/248146"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=248136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=248136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=248136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}