0

I have a solution using to projects: a class library project, and a console application referencing this. Now when I try to debug the console application, it loads the class library from the GAC, not the version from the "sister project" of the solution. I just have changed one line of code in the class library project, and the debugger now just shows me the disassembly instead of the C# source code for methods in the class library.

How can I get VS2015 to load the assembly version from the sister project, not the version from the GAC?

FrankPl
  • 573
  • 4
  • 19
  • Whether two projects are in the same solution? As you said that you add it as the reference, do you set the copy local=true for this assembly in the property window? how do you know the class library is from the GAC? Maybe a screen shot would be better. But as far as I know, if two projects are in the same solution and set the correct property, the assembly will be copied to the Bin/Debug folder of the Console app after you build your solution. – Jack Zhai Apr 23 '18 at 07:05
  • @JackZhai-MSFT Yes, both projects are in the same solution. Copy-local is set to True in the reference. I think I saw that the path of the referenced dll contained GAC_MSIL when I debugged. However, I managed to debug by removing the dll from the GAC and later re-deploying it. Not a clean solution, but a working workaround. – FrankPl Apr 24 '18 at 07:41
  • If the same dll fire was in the GAC, I think you don't need to add the same dll file(Project) as the reference again. Maybe they are different version(32 bit or 64 bit): https://stackoverflow.com/questions/19422573/why-a-dll-is-copied-from-gac-to-project-bin-folder, but if they are all the same version, I think the GAC version would be used firstly:https://stackoverflow.com/questions/981142/dll-in-both-the-bin-and-the-gac-which-one-gets-used – Jack Zhai Apr 24 '18 at 08:16
  • Yes, that was the problem: I had changed one line of code, and was hoping to be able to debug into this changed dll directly in Visual Studio without needing to re-deploy it to the GAC. Apparently, this is not possible. Also, it would mean I have to deploy the debug version of the dll to the GAC, and there is no way to have a release version deployed to the GAC, and still use the debug version from the development environment for debugging. So on the development machine, I need to constantly change the contents of the GAC. – FrankPl Apr 24 '18 at 09:13
  • Anyway, since it is resolved now, I just post it as the answer. If I get other better solution, I will edit and share it.Have a nice day:) – Jack Zhai Apr 24 '18 at 09:30

1 Answers1

0

If the same dll file was in the GAC, it would be loaded firstly, I think it is the reason why it ignored the reference project. So if you really want to use the project reference, you really need to remove the GAC.

Of course, other members also provided the suggestion like using the version numbers:

https://social.msdn.microsoft.com/Forums/en-US/af5086ad-a2b6-4707-b593-0ca4f5518a6a/force-use-of-local-assembly-instead-of-gac?forum=clr

Jack Zhai
  • 6,230
  • 1
  • 12
  • 20