none
Referencing assemblies in the GAC vs. a local appllication directory RRS feed

  • Question

  • I have a C# (I am using VS2012) project that, when I checked it out of TFS, seemed to already reference an assembly in the GAC, but the DLL version I found in the GAC is incorrect and older than what the application expects, so I cannot build.  Another developer here told me that all the applications are "self-contained," which would imply that they do NOT reference assemblies in the GAC.

    My question is, if a project has a reference to a DLL that is not in the project's bin folder (or elsewhere in the project folder structure), does Visual Studio look for and automatically "fix up" the reference for the same DLL if it finds it in the GAC?  I did not think it did that, and have always had a lot of assembly reference headaches when anything changes, so I am a little confused as to how this project came out of TFS already pointing to an assembly in the GAC (albeit the wrong version.)  Since the code expects classes, properties, and methods that do not exist in the older version of the assembly in the GAC, I cannot build.

    Thanks in advance for any tips on this kind of problem.

    • Moved by Amanda Zhu Friday, January 9, 2015 9:26 AM better forum
    Thursday, January 8, 2015 1:03 PM

Answers

  • Hello PeterH084,

    >> if a project has a reference to a DLL that is not in the project's bin folder (or elsewhere in the project folder structure), does Visual Studio look for and automatically "fix up" the reference for the same DLL if it finds it in the GAC? 

    Since you application would load assembly in GAC, it should be strong named assembly, for such kind assemblies, the CLR would search for below location in order:

    1. the global assembly cache

    2. If there is a defined codebase, search for codebase definition and if the codebase specified path not found, it throws an error

    3. The program's root directory

    4. In the root directory, and the name of the referenced assembly subdirectories

    5. In the a private subdirectory of the root directory

    So it would firstly check the GAC, usually, I would do not deploy my private assembly to GAC and deploy it to the application directory as bin folder.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 9, 2015 9:43 AM
    Moderator

All replies

  • Hi,

    Visual Studio General Forum is to discuss VS IDE issues. Common Language Runtime Internals and Architecture forum is a better forum for your issue, so I moved this thread there. YOu will get better response there.

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 9, 2015 9:27 AM
  • Hello PeterH084,

    >> if a project has a reference to a DLL that is not in the project's bin folder (or elsewhere in the project folder structure), does Visual Studio look for and automatically "fix up" the reference for the same DLL if it finds it in the GAC? 

    Since you application would load assembly in GAC, it should be strong named assembly, for such kind assemblies, the CLR would search for below location in order:

    1. the global assembly cache

    2. If there is a defined codebase, search for codebase definition and if the codebase specified path not found, it throws an error

    3. The program's root directory

    4. In the root directory, and the name of the referenced assembly subdirectories

    5. In the a private subdirectory of the root directory

    So it would firstly check the GAC, usually, I would do not deploy my private assembly to GAC and deploy it to the application directory as bin folder.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 9, 2015 9:43 AM
    Moderator