question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows forms: Designer error "Value cannot be null. (Parameter 'propertyName') "

See original GitHub issue

.NET Version: 5.0 VS2019 and VS2022 TargetFramework for all projects I tested is net5.0-windows.

  • Have you experienced this same bug with .NET Framework?: No

Problem description:

My team are currently unable to load any of the Windows forms in our Visual Studio project due to this error: Value cannot be null. (Parameter ‘propertyName’)

This error occurs when we double click on the [Dialog]Dlg.cs file for any of our Windows forms. This happens for all forms in one quite large project which is a startup project in our solution (we have 20 different forms).

If I try to add a new form to this project it has the same issue, if I try to add a new form to some other project in the same solution it works propertly.

I went back to VS 16.8.0 and SDK 5.0.100 and it works well, I can open the form in designer mode. but for VS 16.9.4 is still broken.

The output is as follows in 16.9.4:

Here is part of the Output log when I run a form in the designer:


[10:43:20.6132894] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6132894] [SanXpert]:       Processed 'ICSharpCode.SharpZipLib' in 00:00:00.0055407
[10:43:20.6142871] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6142871] [SanXpert]:       Added 'ICSharpCode.SharpZipLib'
[10:43:20.6152839] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6152839] [SanXpert]:       Loaded Microsoft.WindowsAPICodePack in 00:00:00.0013430 [thread 10]
[10:43:20.6192736] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6192736] [SanXpert]:       Processed 'Microsoft.WindowsAPICodePack' in 00:00:00.0041457
[10:43:20.6202707] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6202707] [SanXpert]:       Added 'Microsoft.WindowsAPICodePack'
[10:43:20.6222659] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6222659] [SanXpert]:       Loaded Microsoft.WindowsAPICodePack.Shell in 00:00:00.0017161 [thread 10]
[10:43:20.6611620] StreamJsonRpc.RemoteInvocationException: Value cannot be null. (Parameter 'propertyName')
                      at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__143`1.MoveNext()
                   --- End of stack trace from previous location where exception was thrown ---
                      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                      at Microsoft.DotNet.DesignTools.Client.Host.ServerHost.<InitializeAsync>d__15.MoveNext()
                   --- End of stack trace from previous location where exception was thrown ---
                      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                      at Microsoft.DotNet.DesignTools.Client.DesignToolsClientLoader.<CreateClientAsync>d__28.MoveNext()
                   --- End of stack trace from previous location where exception was thrown ---
                      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                      at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
                   RPC server exception:
                   System.ArgumentNullException: Value cannot be null. (Parameter 'propertyName')
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.ResXGlobalObject.ResourceGlobalObject..ctor(ResXGlobalObject globalObject, ResXDataNode node, Type resourceType, String resourceName, String propertyName, String combinedName)
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.ResXGlobalObject.BuildType()
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.ResXGlobalObject.GetObjectType()
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.GlobalObject.get_ObjectType()
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.ResXGlobalObject.get_Children()
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.ProjectResXGlobalObjectProvider.AddResourcesToGlobalCollection(String identifier, GlobalResourceFileData globalResource)
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.ProjectResXGlobalObjectProvider.UpdateGlobalObjectCollectionStoreForSource(String identifier)
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.GlobalObjectProvider.InitializeOrUpdateProjectResources(GlobalResourceFileData[] resources)
                         at Microsoft.DotNet.DesignTools.Server.GlobalObjects.GlobalObjectService.InitializeOrUpdateGlobalResources(GlobalResourceFileData[] globalResources)
                         at Microsoft.DotNet.DesignTools.Server.DesignToolsServer.InitializeAsync(ServerInitializationOptions options)
                   
[10:43:20.6791137] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6791137] [SanXpert]:       Processed 'Microsoft.WindowsAPICodePack.Shell' in 00:00:00.0574316
[10:43:20.6831026] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6831026] [SanXpert]:       Added 'Microsoft.WindowsAPICodePack.Shell'
[10:43:20.6831026] [SanXpert]: info: Microsoft.DotNet.DesignTools.Services.TypeResolutionService[0]
[10:43:20.6831026] [SanXpert]:       Loaded Accessibility in 00:00:00.0003100 [thread 10]

Expected behavior: When I click on the xxxDlg.cs file associated with a Windows form, I should see the form designer.

Minimal repro: It should be possible to repro this issue by loading a large project, designed in an older version of Visual Studio, and double clicking on one of the .cs files which usually loads the form designer view. The form designer view does not work in the new VS versions.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
RussKiecommented, Mar 17, 2022

The fix will go out in 17.2 Preview3

0reactions
RussKiecommented, Mar 17, 2022

I spent some time tinkering with MSBuild, and I think the following workaround should assign correct dependencies to all loc’ed resources with non-standard locale names:

  <ItemGroup>
    <_EmbeddedResources Include="**\*.resx">
      <_HasLocaleName>$([System.String]::Copy('%(Filename)').IndexOf('.'))</_HasLocaleName>
    </_EmbeddedResources>

    <_EmbeddedResourceWithLocaleNames Include="@(_EmbeddedResources)"
                                      Exclude="@(_EmbeddedResources->HasMetadata('_HasLocaleName')->WithMetadataValue('_HasLocaleName','-1'))" />

    <EmbeddedResource Update="@(_EmbeddedResourceWithLocaleNames)">
      <DependentUpon>$([System.String]::Copy('%(Identity)').SubString(0, $([System.String]::Copy('%(Identity)').IndexOf('.')))).cs</DependentUpon>
    </EmbeddedResource>
  </ItemGroup>

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - VS 2019: Error occurred trying to load Windows Form ...
ArgumentNullException : Value cannot be null. (Parameter 'propertyName') at Microsoft.DotNet.DesignTools.Server.GlobalObjects.
Read more >
Windows Forms Designer error : Value cannot be null. ...
I am developing an app using C# Windows Forms with framework DevExpress. My IDE are Visual Studio Community 2022. It is all okay....
Read more >
Value cannot be null. Parameter name: instance in Reporting
When I try to open the designer in visual studio I get the following error: Value cannot be null. Parameter name: instance
Read more >
Question - Value cannot be null. Parameter name: source
Based on the error message, it's fairly obvious that Login_Form.Upic is null . You have shown us how that property/field is declared or ......
Read more >
[Solved] Value cannot be null. Parameter name: source
This error is usually related to the EF. Try using debugger and narrow down your issue and the post the relevant code and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found