2

I have a legacy project in Visual Studio 2003 that was made in the past by other developers.

This project has some references added. One of them, let's say myDLL.dll. It has the properties below in VS:

  • Copy Local = True
  • Runtime Version v1.1.4322
  • Strong Name: True
  • Type: Assembly
  • Version: 2.1.1.30200

I build the solution and copy it in the target path in production machine. In the target I have ensured that myDLL.dll is the same version as in the VS solution, that is, 2.1.1.30200.

When I executed the new version of the app in production machine below error is shown in my app logs:

The located assembly's manifest definition with name 'myDLL' does not match the assembly reference.

I guess that in GAC is loaded/installed a previous version of this DLL so hence the above exception.

So, I wonder if GAC is automatically cleaned from time to time (on a regular basis) or do I need to remove manually the old DLL and install the new one?

If I need to remove the old one and install the new one in the production machine, how can I do it?

Additionally, if I go to C:\Windows\assembly in production machine I can find the DLL myDLL but the version indicated is 2.1.0.0 instead of 2.1.x.x. Why? Shouldn't it be 2.1.1.30200 (for the new one) or 2.1.1.20100 (for the old one)?

I have read a lot of posts here, like below ones:

Other interesting links that I have found:

but I am very newbie in GAC.

Willy
  • 9,848
  • 22
  • 141
  • 284
  • Use [fuslogvw](https://learn.microsoft.com/en-us/dotnet/framework/tools/fuslogvw-exe-assembly-binding-log-viewer) or [Process Monitor](https://learn.microsoft.com/en-us/sysinternals/downloads/procmon) to find out which DLL is actually loaded and let us know. – Wernfried Domscheit Jun 15 '18 at 09:57
  • How does your reference look like in your `.csproj` file? – Wernfried Domscheit Jun 15 '18 at 10:05

1 Answers1

0

Have you tried to put the myDLL.dll into the same directory where your output program is located? For web projects it is "bin" directory, for EXE just keep them together in the same folder. So it will be loaded from application directory, not from the GAC.

Tiber Septim
  • 315
  • 3
  • 11
  • It is a legacy winform app. The DLL is in the same directory where executable file is. I thought that when app is launched and it needs the DLL to be loaded in memory, it goes first to GAC in order to search for it. If DLL is not found in GAC then it goes to application directory and loads the DLL from there and put it in GAC. In case it is in GAC, then it loads from there and check the version and if the version is not the same then this error is thrown. So am I confused then? it does not work in this way? – Willy Jun 15 '18 at 09:47
  • If it loads the DLL from the app directory as you say and the DLL version in app directory is the correct, then why it is throwing this kind of error? – Willy Jun 15 '18 at 09:49
  • 1
    That's wrong. Files in GAC takes precedence over files in application directory, see https://learn.microsoft.com/en-us/dotnet/framework/deployment/how-the-runtime-locates-assemblies – Wernfried Domscheit Jun 15 '18 at 10:01
  • @WernfriedDomscheit Correct, this is how I had understood.Thanks for confirming it. – Willy Jun 15 '18 at 13:57