I have a solution with multiple projects inside. The first is a class library, the others are the console application and a unit test project. The problem is the first time I ran the console app or unit test project, everything seemed okay, but after several times, any changes I made to the class library were not updated to other projects. When I debug in, the code keeps referring to the old code of the class library instead of the new one. For example, my class library has code like this
public void PrintLine()
{
Console.WriteLine("Old code");
}
After I updated it to this
public void PrintLine()
{
Console.WriteLine("New code");
}
After cleaning and rebuilding the solution, and re-add references for other projects, it still prints out "Old Code"
Thing I've tried
I'm not sure why that happens. I try creating a new project and this thing happens again just after a few runs
Update
After struggling for 1 night, I found that in the modules call, the DLL of the class library I'm referring to is in a different path instead of the bin/debug I've set. This dll file was created 2 days ago, I don't know how and when but after deleting it, thing seems working again
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\(Class library name)
You can find the dll with the corresponding name in the C:\Windows\Microsoft.NET\assembly\GAC_MSIL path and delete it.
GAC_MSIL is a folder in the Global Assembly Cache. The Global Assembly Cache is a special location used to store and manage shared .NET assemblies. In the .NET Framework, an assembly is a unit of code base that can contain a set of related classes, interfaces, and other types of definitions.
Assemblies in the GAC have a certain priority because they are globally shared. When multiple applications require the same version of an assembly, the assembly will be called first to ensure that they are using the same assembly.