Search code examples
visual-studio-2022csprojsln-file

Why does Visual Studio 2022 display an error message when editing dependencies "String value ' ' cannot be translated to any value from System.Guid."?


I have a project which I am using as a simple testbed for a graphical application. I am attempting to add a shared project file (.shproj), but whenever I try to edit the project's dependencies, I get a dialog which says:

---------------------------
Microsoft Visual Studio
---------------------------
String value '

      ' cannot be translated to any value from type System.Guid.
---------------------------
OK   
---------------------------

This happens if I right-click on my project and select either **Add Project Reference..." or "Add Shared Project Reference..."

enter image description here

enter image description here

Unfortunately I do not have this project as part of source control so I can't go back in time to see what may have caused this problem. I have attempted to undo the operations which may have gotten me into this state (such as adding the .shproj to my solution) but the dialog still appears when I attempt to edit the dependencies.

I haven't been able to find anything online about this error, and I suspect it's happening because something is malformed in either my .csproj or the .sln, but I'm not sure where to look or what to try to solve this.

I am running Visual Studio 2022 (17.4.2).

I have tried opening the project in Visual Studio 2019 and I can edit the dependencies there. I can also add and remove nuget packages. Note that if I modify the dependencies in Visual Studio 2019, the project will correctly load and build in 2022 so I do have a workaround. However, it would be nice to know why the project dependencies cannot be edited in 2022.


Solution

  • It turns out that empty Project tags caused problems in the .csproj file.

    My .csproj file referenced other .csproj files and these references included empty Project tags.

    Here is a snippet before the fix:

    <ProjectReference Include="../../../GitHub/FlatRedBall/Engines/FlatRedBallXNA/FlatRedBallDesktopGLNet6/FlatRedBallDesktopGLNet6.csproj">
      <Name>FlatRedBallDesktopGLNet6</Name>
      <Project>
      </Project>
    </ProjectReference>
    

    Removing the Project tags solves this problem, as shown in the following code:

    <ProjectReference Include="../../../GitHub/FlatRedBall/Engines/FlatRedBallXNA/FlatRedBallDesktopGLNet6/FlatRedBallDesktopGLNet6.csproj">
      <Name>FlatRedBallDesktopGLNet6</Name>
    </ProjectReference>