How to fix "Could not load file or assembly" when opening Visual Studio

drago314 10 Reputation points
2023-07-11T17:04:26.75+00:00

When I open Visual Studio 2022, I receive the error:

Could not load file or assembly

'Microsoft.VisualStudio.Diagnostics.Assert, Version=17.0.0.0, Culture=neutral, PublicKeyToken=---------------'

I have tried to repair the installation, rebooted the computer, and uninstalled/reinstalled the Visual Studio uninstaller. Unsure what could be causing the problem or how to fix it.

I am attempting to use Visual Studio for Unity Game Dev. I had it working before on the 2017 version, but I uninstalled it for disk space at some point.

Developer technologies Visual Studio Setup
Developer technologies Visual Studio Other
{count} vote

3 answers

Sort by: Most helpful
  1. drago314 10 Reputation points
    2023-07-12T02:43:24.17+00:00

    This is OP:

    I was able to solve the problem by installing the 2019 version of Visual Studio, even though the current version and the 2017 version still both do not work.

    Before installing the 2019 version I uninstalled all visual studio installations and the installer software, and then deleted all files/folders on my computer with "Visual studio" in their name. I am unsure if this actually helped, however. It may just be that the 2019 version does not have this issue.

    1 person found this answer helpful.

  2. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2023-07-12T06:51:06.31+00:00

    Hello @drago314 , @Hoang Duc Manh ,

    Welcome to Microsoft Q&A forum.

    There are many causes about this error. The error message mentioned “could not load it”, so maybe something blocked it from loading(e.g. permission limitation), maybe the assembly file was corrupted so VS failed to load it, maybe the assembly file is missing or maybe there’s a different version of the same assembly file which was also detected by VS and cause confliction…

    The Microsoft.VisualStudio.Diagnostics.Assert.dll(version 17.0.0.0) file is stored in C:\Program Files\Microsoft Visual Studio\2022\edition\Common7\IDE\PrivateAssemblies folder. Since you have repaired and reinstalled VS, I think it exists and is good for using. Perhaps you need to check if there’s a different/same version of Microsoft.VisualStudio.Diagnostics.Assert.dll file which was installed in GAC(Global Assembly Cache) by running gacutil -l command in VS Developer Command Prompt. Try to uninstall it by using gacutil -u Microsoft.VisualStudio.Diagnostics.Assert command(you may backup the assembly first in %windir%\Microsoft.NET\assembly folder).

    Besides, some other extensions/programs which are working/running along with VS may affect the loading process. You may try reinstalling them or, uninstalling them > reinstalling VS > reinstalling them. For permission issues, you may try running VS as administrator. For other cache issues, try resetting VS(run devenv /ResetSettings command in VS Developer Command Prompt) and if you previously modified some other things like Registry, system file, system settings, try recovering them and test again.

    Anyways, I'm happy to hear that installing VS 2019 solved your issue.

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

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.