I have a .Net-framework 4.8 project which fails to load in Visual Studio 2022 and I simply don't know why.
The error occurs when attempting to open the properties of the project inside Visual Studio.
An error occured while loading the project properties editor.
the error message as image
The projects also show an error symbol in the solution explorer, but nothing further is stated:
I've had an identical issue with another project, but that was resolved by removing an illegal property.
On my current project, that property is already removed but the error still exists and won't resolve. I don't understand what is happening under the hood.
System.ArgumentException: Expected 1 values for property Build::DefineConstants, but got 0.
Parameter name: values
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.Property.Update(ImmutableArray`1 values)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.Property..ctor(PropertyMetadata metadata, ImmutableArray`1 values, PropertyContext context, ImmutableHashSet`1 varyByDimensions)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.PropertyContextFactoryBase.ToProperty(IUIProperty property, Page page, Category category, Int32 order, PropertyContext propertyContext, IPropertyEditorRegistry propertyEditorRegistry)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.ProjectPropertyDataAccess.Observer.<HandleDataAsync>g__CreateProperties|14_5(<>c__DisplayClass14_0& )
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.ProjectPropertyDataAccess.Observer.<HandleDataAsync>g__ProcessInitialData|14_1(<>c__DisplayClass14_0& )
--- 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.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.ProjectPropertyDataAccess.Observer.<InitializeAsync>d__10.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 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.ProjectPropertyDataAccess.Observer.<CreateAsync>d__9.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.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.ProjectPropertiesEditor.<>c__DisplayClass0_0.<<-ctor>b__0>d.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.VisualStudio.ProjectSystem.VS.Implementation.PropertyPages.Designer.AsyncLoadContent.<>c__DisplayClass0_0.<<Initialize>b__0>d.MoveNext()
Here is the project file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Testcenter.RobotFramework.Exceptions</RootNamespace>
<AssemblyName>Testcenter.RobotFramework.Exceptions</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<DefineConstants>DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Testing|AnyCPU' ">
<OutputPath>bin\Testing\</OutputPath>
<DefineConstants>TEST</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Libraries|AnyCPU' ">
<OutputPath>bin\Libraries\</OutputPath>
<DefineConstants>ONLY_LIBRARY</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Testcenter.RobotFramework.Exceptions</PackageId>
<Version>1.0.0</Version>
<Authors>Testcenter Team, Some person</Authors>
<Company>Some company</Company>
<PackageOutputPath>$(ProjectDir)</PackageOutputPath>
<Description>A class library providing exception types used in the implementation itself and in keyword libraries.</Description>
<Title>RobotFramework Remote-Library-Interface for C# (exception types)</Title>
<Copyright>Copyright (c) Some company 2022</Copyright>
<RepositoryUrl>https://redacted-url.com/repos/testcenter.robotframework/browse</RepositoryUrl>
<Product>Testcenter.RobotFramework.Exceptions</Product>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<!-- Properties which cause problems in Visual Studio. The error doesn't occur if these are commented out.
More info here: https://stackoverflow.com/questions/75098414/unrelated-loading-error-when-adding-nuget-package-information-to-a-net-framewor
<TargetFramework>net48</TargetFramework> -->
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\ConfigurationException.cs" />
<Compile Include="Configuration\KeywordConfigurationException.cs" />
<Compile Include="Configuration\ServerConfigurationException.cs" />
<Compile Include="Keyword\ContinuableKeywordException.cs" />
<Compile Include="Keyword\FatalKeywordException.cs" />
<Compile Include="Keyword\KeywordException.cs" />
<Compile Include="Keyword\NormalKeywordException.cs" />
<Compile Include="Keyword\KeywordLoadingException.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NuGet.Build.Tasks.Pack" Version="6.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
The project fails to load only in Visual Studio, but loads fine in JetBrains Rider.
I have a very similar project file (seen in the solution explorer), which loads just fine and has the exact same property structure and the only difference is the NuGet-Package information and the compiled source files.
Here's also my solution file, which maybe contributes to the problem, but I wouldn't know why or how.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcenter.RobotFramework", "Testcenter.RobotFramework\Testcenter.RobotFramework.csproj", "{63B8CCEF-5C50-4F25-8E6B-C623DA1BDD2F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testcenter.RobotFramework.Communication", "Testcenter.RobotFramework.Communication\Testcenter.RobotFramework.Communication.csproj", "{86F3BACB-FC4D-43FC-BA20-659600C6134C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testcenter.RobotFramework.Exceptions", "Testcenter.RobotFramework.Exceptions\Testcenter.RobotFramework.Exceptions.csproj", "{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RobotFramework", "RobotFramework", "{1F0EA3DB-C080-432A-9948-DF8461982CDE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{0A74D269-D322-40B9-9193-AC95B08DA488}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcenter.RobotFramework.Test", "testcenter.robotframework.testing\Testcenter.RobotFramework.Test.csproj", "{2079E935-E4C0-460D-A9F1-215E4319C85C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RobotLibraries", "RobotLibraries", "{0B0D45E9-0A08-430D-8BF5-219E15465804}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcenter.RobotLibrary.Deditec", "Testcenter.RobotLibrary.Deditec\Testcenter.RobotLibrary.Deditec.csproj", "{C04EA17A-0B86-4180-885D-9EAEC9D5D6DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcenter.RobotLibrary.Extension", "Testcenter.RobotLibrary.Extension\Testcenter.RobotLibrary.Extension.csproj", "{6E2D959E-9E66-4402-8E06-1DF0497BC92D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI/CD", "CI/CD", "{F691C5B2-2CF5-445C-A2A1-29F480129B6E}"
ProjectSection(SolutionItems) = preProject
dockerfile = dockerfile
.dockerignore = .dockerignore
.cicd\hello-world-pipeline.yml = .cicd\hello-world-pipeline.yml
.cicd\robotframework-release-pipeline.yml = .cicd\robotframework-release-pipeline.yml
.cicd\scripts\build-solution-or-project.ps1 = .cicd\scripts\build-solution-or-project.ps1
.cicd\scripts\push-nuget-package.ps1 = .cicd\scripts\push-nuget-package.ps1
.cicd\tasks\msbuild-project.yml = .cicd\tasks\msbuild-project.yml
.cicd\tasks\push-nuget.yml = .cicd\tasks\push-nuget.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcenter.RobotLibrary.HCS.Roombus", "Testcenter.RobotLibrary.HCS.Roombus\Testcenter.RobotLibrary.HCS.Roombus.csproj", "{80A1F57E-39D0-4E33-B8CB-27033FBAEBF4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Libraries|Any CPU = Libraries|Any CPU
Release|Any CPU = Release|Any CPU
Testing|Any CPU = Testing|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63B8CCEF-5C50-4F25-8E6B-C623DA1BDD2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63B8CCEF-5C50-4F25-8E6B-C623DA1BDD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63B8CCEF-5C50-4F25-8E6B-C623DA1BDD2F}.Libraries|Any CPU.ActiveCfg = Libraries|Any CPU
{63B8CCEF-5C50-4F25-8E6B-C623DA1BDD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63B8CCEF-5C50-4F25-8E6B-C623DA1BDD2F}.Release|Any CPU.Build.0 = Release|Any CPU
{63B8CCEF-5C50-4F25-8E6B-C623DA1BDD2F}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{86F3BACB-FC4D-43FC-BA20-659600C6134C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86F3BACB-FC4D-43FC-BA20-659600C6134C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86F3BACB-FC4D-43FC-BA20-659600C6134C}.Libraries|Any CPU.ActiveCfg = Libraries|Any CPU
{86F3BACB-FC4D-43FC-BA20-659600C6134C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86F3BACB-FC4D-43FC-BA20-659600C6134C}.Release|Any CPU.Build.0 = Release|Any CPU
{86F3BACB-FC4D-43FC-BA20-659600C6134C}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C}.Libraries|Any CPU.ActiveCfg = Libraries|Any CPU
{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C}.Release|Any CPU.Build.0 = Release|Any CPU
{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{2079E935-E4C0-460D-A9F1-215E4319C85C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2079E935-E4C0-460D-A9F1-215E4319C85C}.Libraries|Any CPU.ActiveCfg = Libraries|Any CPU
{2079E935-E4C0-460D-A9F1-215E4319C85C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2079E935-E4C0-460D-A9F1-215E4319C85C}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{2079E935-E4C0-460D-A9F1-215E4319C85C}.Testing|Any CPU.Build.0 = Testing|Any CPU
{C04EA17A-0B86-4180-885D-9EAEC9D5D6DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C04EA17A-0B86-4180-885D-9EAEC9D5D6DC}.Libraries|Any CPU.ActiveCfg = Libraries|Any CPU
{C04EA17A-0B86-4180-885D-9EAEC9D5D6DC}.Libraries|Any CPU.Build.0 = Libraries|Any CPU
{C04EA17A-0B86-4180-885D-9EAEC9D5D6DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C04EA17A-0B86-4180-885D-9EAEC9D5D6DC}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{C04EA17A-0B86-4180-885D-9EAEC9D5D6DC}.Testing|Any CPU.Build.0 = Testing|Any CPU
{6E2D959E-9E66-4402-8E06-1DF0497BC92D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E2D959E-9E66-4402-8E06-1DF0497BC92D}.Libraries|Any CPU.ActiveCfg = Libraries|Any CPU
{6E2D959E-9E66-4402-8E06-1DF0497BC92D}.Libraries|Any CPU.Build.0 = Libraries|Any CPU
{6E2D959E-9E66-4402-8E06-1DF0497BC92D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E2D959E-9E66-4402-8E06-1DF0497BC92D}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{6E2D959E-9E66-4402-8E06-1DF0497BC92D}.Testing|Any CPU.Build.0 = Testing|Any CPU
{80A1F57E-39D0-4E33-B8CB-27033FBAEBF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80A1F57E-39D0-4E33-B8CB-27033FBAEBF4}.Libraries|Any CPU.ActiveCfg = Libraries|Any CPU
{80A1F57E-39D0-4E33-B8CB-27033FBAEBF4}.Libraries|Any CPU.Build.0 = Libraries|Any CPU
{80A1F57E-39D0-4E33-B8CB-27033FBAEBF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80A1F57E-39D0-4E33-B8CB-27033FBAEBF4}.Testing|Any CPU.ActiveCfg = Testing|Any CPU
{80A1F57E-39D0-4E33-B8CB-27033FBAEBF4}.Testing|Any CPU.Build.0 = Testing|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{63B8CCEF-5C50-4F25-8E6B-C623DA1BDD2F} = {1F0EA3DB-C080-432A-9948-DF8461982CDE}
{86F3BACB-FC4D-43FC-BA20-659600C6134C} = {1F0EA3DB-C080-432A-9948-DF8461982CDE}
{DA53C3E0-7D05-4BB7-932C-97147BFB0E4C} = {1F0EA3DB-C080-432A-9948-DF8461982CDE}
{2079E935-E4C0-460D-A9F1-215E4319C85C} = {0A74D269-D322-40B9-9193-AC95B08DA488}
{C04EA17A-0B86-4180-885D-9EAEC9D5D6DC} = {0B0D45E9-0A08-430D-8BF5-219E15465804}
{6E2D959E-9E66-4402-8E06-1DF0497BC92D} = {0B0D45E9-0A08-430D-8BF5-219E15465804}
{80A1F57E-39D0-4E33-B8CB-27033FBAEBF4} = {0B0D45E9-0A08-430D-8BF5-219E15465804}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B25855F-6BB5-44FA-8793-5F3E05270044}
EndGlobalSection
EndGlobal
Just to give this a definitive answer and also for anyone else stumbling upon this.
The issue was solved together with Microsoft Support: https://developercommunity.visualstudio.com/t/Error-on-opening-project-properties-for-/10416753
The issue came up since in the solution file, there was a wrong Project GUID and Visual Studio attempted to load the project as an SDK-Style project. But in fact they weren't supposed to be SDK-Style projects.
The issue was resolved by manually changing all affected GUIDs to the correct one.
Here is a quote of the problem resolution:
Looking at the solution file you provided I see the following entries (edited for clarity):
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcenter.RobotFramework", <project path>, <project ID>
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Testcenter.RobotFramework.Communication", <project path>, <project ID>
EndProject
The first GUID on each line (
“FAE04EC0-301F-11D3-BF4B-00C04F79EFBC”
and“9A19103F-16F7-4668-BE54-9A1E7A4F7556”
) tells Visual Studio which component should handle loading the project. Since these are not SDK-style projects I would expect both GUIDs to be“FAE04EC0-301F-11D3-BF4B-00C04F79EFBC”
. The“9A19103F-16F7-4668-BE54-9A1E7A4F7556”
GUID will causeTestcenter.RobotFramework.Communication.csproj
to load with the wrong component, which won’t fully understand it. This can lead to the sort of errors you reported.Can you try the following and let us know if it fixes things for you?
- Close Visual Studio.
- Open your .sln file in a text editor.
- Replace all occurrences of the
“9A19103F-16F7-4668-BE54-9A1E7A4F7556”
GUID with“FAE04EC0-301F-11D3-BF4B-00C04F79EFBC”
- Save the .sln file
- Re-open the solution in Visual Studio.