“Copy Local = false” referenced project shows “Could not load file or assembly”

自闭症网瘾萝莉.ら 提交于 2019-12-11 02:26:45

问题


I have spent days looking for an answer but have not figured out what happens.

I have a solution with 4 projects. One of them is referenced to other 3. All references are set "copy local = false".

I have made output folders for each of them and everything was going great, until I decided to change the output folder. :-(

Now when I reference the project to another with property "copy local = false" project does not load and I have an error saying

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

I am quite sure from the FusionLog of the error that Studio is still looking for the project's .dll at the old path.

When I set "copy local = true" projects runs but this solution is not acceptable.

What should I do so I can load my project again with copy local set to false? How can I change the path that Visual Studio is looking? Is there a cache that I can clear or update?

Thanks in advance for any help on this.


回答1:


Add this to your dependant project's app.config (I.E. the project that has the dependencies on the other projects):

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="*relative path to assemblies here*" />
    </assemblyBinding>
</runtime>

With 'relative path to assembly here' replaced with the actual relative paths to where the assemblies are built (your new output folder(s)).

MSDN




回答2:


  1. Take a backup copy of your entire solution (all files)
  2. Locate your solution (.sln) file.
  3. Right click on its icon and select "Open with" and then select NotePad or a similar text editor.
  4. Search for part or all of the old path.
  5. If you find it in the file, replace all instances of the old path with the new path.
  6. Save the file.


来源:https://stackoverflow.com/questions/17837609/copy-local-false-referenced-project-shows-could-not-load-file-or-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!