Concerns Regarding Changing the GAC

RogerSchlueter-7899 1,346 Reputation points
2023-01-26T21:13:16.5333333+00:00

I am getting this error:

Could not load type 'System.DateTime?' from assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Based on other comments, I looked into the GAC and this is listed:

System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

So the GAC has an outdated version of the assembly. I infer that this is why I am getting the error message. But the question is what to do:

  • Is removing that assembly from the GAC the solution? If so, can I safely remove it?
  • Do I need to add Version 6? If so, how?

Thanks in advance.

Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,023 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 33,271 Reputation points Microsoft Vendor
    2023-01-30T07:35:42.22+00:00

    Hello @RogerSchlueter-7899 ,

    Welcome to Microsoft Q&A forum.

    There are ways to easily remove an assembly from the GAC(Global Assembly Cache), but see this document: How to: Remove an Assembly from the Global Assembly Cache:

    Warning

    You should not use Gacutil.exe to remove assemblies on production systems because of the possibility that the assembly may still be required by some application. Instead, you should use the Windows Installer, which maintains a reference count for each assembly it installs in the GAC.

     

    Note

    Windows Installer maintains a reference count for assemblies installed in the GAC. An assembly is removed from the GAC only when its reference count reaches zero, which indicates that it is not used by any application installed by a Windows Installer package.

     

    What about installing/adding a higher version of the same assembly into the GAC or setting some configurations to let the project find and use the specific installed version of assembly? Perhaps installing the correct version of the assembly is the solution(Did you miss to install any component maybe? Try to install this NuGet package: System.Runtime). BTW, maybe bindingRedirect is needed.

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.