Project References DLL version hell

后端 未结 10 1071
离开以前
离开以前 2020-12-28 16:19

We\'re having problems getting visual studio to pick up the latest version of a DLL from one of our projects.

We have multiple class library projects (e.g. Business

相关标签:
10条回答
  • 2020-12-28 16:58

    To avoid the dll hell I would recommend you to create a lib folder inside your project and put all shared assemblies in this folder. Next you Add References only from this folder. This way your project is self contained and you know exactly where it is picking the references from. If you want to update some assembly with a newer version you copy it to the lib folder and rebuild your project.

    Also make sure you don't the referenced assemblies into the GAC as they might be picked up first.

    0 讨论(0)
  • 2020-12-28 17:06

    Check Out this things:

    1. if problematic dll were referenced by both host web application and its referenced one. e.g. say, your web application uses abc.dll (problematic) and 1 other dll xyz.dll(i.e. class project which also reference abc.dll).

    In this case, suppose, you've updated abc.dll from version 1 to version 2 and re-referenced in your web application. but during building process, the version 2 of abc.dll will change back to version 1, because, xyz.dll uses version 1 and web application overwrite abc.dll version 2 back to abc.dll version 1 during auto update on xyz.dll.

    Solution: place updated version of abc.dll version 2 in class project bin of xyz.dll , too

    Hope, above details will help, good luck

    0 讨论(0)
  • 2020-12-28 17:08

    To overcome this, I removed EVERY reference, then added them all back in again. I don't know why this is the solution.

    It is possible that in one project a DLL was incorrect, and it is this incorrect DLL that was pulled through by visual studio and used.

    Edit: Other times this error has occurred is due to a DDL (A) being referenced in the current project also being referenced by another DLL (B). Not rebuilding this other DLL (B) seems to prevent VS from referencing the correct version of DLL (A) in the current project and thus it brings through an older version of DLL (A).

    0 讨论(0)
  • 2020-12-28 17:09

    Have you tried adding the reference as a Project Reference? i.e. Add Reference... -> Projects tab -> Select your project

    0 讨论(0)
提交回复
热议问题