Winforms designer does not work after update to preview 3

Hans 251 Reputation points
2021-01-29T13:10:25.073+00:00

Hi,

Ik made a small winform test in preview 2 with .net5. Now installed preview 3 and I can't open a form anymore in de designer. the error is:

Unable to find method 'InitializeAsync/1' on {no object} for the following reasons: Deserializing JSON-RPC argument with name "options" and position 0 to type "Microsoft.DotNet.DesignTools.Protocol.Server.ServerInitializationOptions" failed: Expected JSON token PropertyName, but it was EndObject.

I found the same question here but it has not been answered yet. So I hope that some here knows a solution.

Greetings

Developer technologies | Windows Forms
{count} votes

Accepted answer
  1. Hans 251 Reputation points
    2021-01-29T19:00:51.293+00:00

    Hi,

    I tried to start a new project and that failed to. But after I repaired the Visual studio installation the error is gone. Everything seems to work fine now.
    Repairing the installation was the solution.

    Greetings

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2021-01-29T14:33:36.857+00:00

    Hello,

    .NET 5 is out of preview, see the following download page.

    If you double click on the project file in Solution Explorer you should have the following for C# 9, .NET5

    <Project Sdk="Microsoft.NET.Sdk">  
      
    	<PropertyGroup>  
    		<OutputType>WinExe</OutputType>  
    		<LangVersion>latest</LangVersion>  
    		<TargetFramework>net5.0-windows</TargetFramework>  
    		<RootNamespace>Async_Enumerables</RootNamespace>  
    		<UseWindowsForms>true</UseWindowsForms>  
    	</PropertyGroup>  
    </Project>  
    

    Under the project properties
    61866-11111111111.png

    Important

    Once the following has been done

    • Right click on the project in solution explorer, select clean.
    • Right click on the project in solution explorer, select build.

    Make sure there is a reference to System.Text.Json which can be using NuGet using this package or for Json.NET use this package.

    0 comments No comments

  2. Hans 251 Reputation points
    2021-01-29T16:08:18.777+00:00

    Hi,

    In Options I had .net5 selected. I tried clean and build. The program was already building well. I changed the first line and this is now a part of my project file:

    <Project Sdk="Microsoft.NET.Sdk">  (This line was: <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">)
    
      <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net5.0-windows</TargetFramework>
        <UseWindowsForms>true</UseWindowsForms>    
        <Platforms>AnyCPU;x64</Platforms>
      </PropertyGroup>
    
      ...
    
    </Project>  
    

    I now got the system.txt.json with the nuget package manager. (using System.Text.Json; did work without it)

    I still can't open a form. I get the same error.

    Greetings


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.