Search code examples
c#dependenciesnugetnpm-install

Could not load file or assembly 'XXXXXX' or one of its dependencies. The system cannot find the file specified


Problem statement:

I am setting up my project. When I build the project/solution. Project build successfully but I am getting this run time error

Could not load file or assembly 'XXXX' or one of its dependencies. The system cannot find the file specified.

Tried Solutions:

Below are the steps I have tried to resolve the issue:

  • Deleted the source code, Taken fresh/ clone of the repository (Build the project where at the solution level Manage Package Level Solution-> Package Source is 'ALL'.)
  • I have updated the XXX package to latest stable version.
  • Solution Configuration to ‘Debug’.
  • Recreated the IIS Application pool. Set Process Model->Identity to My user.
  • Deleted the Bin Folder and Rebuild the solution.
  • Uninstall the VS and installed it again.

I am blocked at this moment due to this issue.

Your kind guidance to resolve the issue is highly appreciated.Feel free to tag the developers who has faced and resolved the issues in the past.

Happy coding!


Solution

  • The problem is now addressed.

    The root cause of the issue was wrong generation of the virtual directory, I have deleted all the applications from the Default web site and deleted all Application pool from IIS (Internet Information Service) Manager. and created them again.

    Diagnosis of issue:

    I was able to diagnose this issue after I have enable the Assembly binding logging, Below are the steps to enable the assembly login:

    1. Search Registry Editor in the start menu and select Open file location. Open the Registry Editor as admin

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion

    Add:

    • DWORD(32-Bit) ForceLog set value to 1
    • DWORD(32-Bit) LogFailures set value to 1
    • DWORD(32-Bit) LogResourceBinds set value to 1
    • DWORD(32-Bit) EnableLog set value to 1
    • String LogPath set value to folder for logs (e.g. C:\FusionLog)

    Make sure you include the backslash after the folder name and that the Folder exists .

    You need to restart the program that you're running(Visual studio) to force it to read those registry settings. Don't forget to turn off fusion logging when not needed.