Visual Studio 2022 could not load file or assembly if opening solution on startup

Brian King 20 Reputation points
2024-02-22T21:31:56.95+00:00

When opening a solution at the time of starting Visual Studio 2022 such as: "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe" "C:\temp\Solution.sln" I get the error: Project Creation Error : 'Mcrosoft.Windows.Design.Host, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. But if I start Visual Studio 2022 without specifying the solution, and then once it is opened, I then use 'File / Open / Solution' and select the same solution - it opens fine without any error. Any suggestions why? Microsoft Visual Studio Professional 2022 (64-bit) - LTSC 17.8
Version 17.8.4 User's image

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,449 questions
{count} votes

Accepted answer
  1. Michael Taylor 57,476 Reputation points
    2024-02-22T21:57:24.2733333+00:00

    Does it matter what type of project(s) are in the solution? In other words if you create a console app as the only project in the solution and try to open it does it fail?

    Without any additional information I'm going to guess the solution previously had a project with some sort of UX open in the designer (e.g. winforms, web forms, WPF, etc). Because everything loads async now the designer is trying to load before everything is initialized.

    If you can provide repro steps that would be useful.

    At any rate I suspect you need to report the issue to the VS team by using the Report a Problem Feature in the top-right corner of Visual Studio.


1 additional answer

Sort by: Most helpful
  1. Pinaki Ghatak 5,575 Reputation points Microsoft Employee
    2024-02-23T17:10:28.6866667+00:00

    Hello Brian King This issue could be due to a variety of reasons, including permission limitations, corrupted or missing assembly files, or conflicts with different versions of the same assembly file. You could try the following:

    1. Move your project to somewhere else besides temp, since UAC restrictions might be kicking in.
    2. Run Visual Studio as an administrator: Right-click on the Visual Studio 2022 shortcut and select "Run as administrator". This can sometimes resolve issues related to file access permissions.
    3. Clear the MEF component cache: You can do this by installing the Clear MEF Component Cache extension from the Visual Studio Marketplace. After installation, go to Tools -> Clear MEF Component Cache and press OK. Visual Studio will restart.
    4. Delete the hidden .vs folder: This folder is located in the same directory as your solution file. It contains user-specific files that Visual Studio uses to cache project information. Deleting it can resolve issues related to corrupted cache files.
    5. Reinstall or repair Visual Studio: If none of the above solutions work, you might consider repairing or reinstalling Visual Studio. You can do this through the Visual Studio Installer.
    6. Check for conflicting assembly files: Use the gacutil -l command in the Visual Studio Developer Command Prompt to list the assemblies installed in the Global Assembly Cache (GAC). If you find a different version of the same assembly file, try uninstalling it using the gacutil -u command.

    If this information provided here helps solve your issue, please tag this as answered, so it helps further community readers, who may have similar questions.

    0 comments No comments

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.