Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8704487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:07:04+00:00 2026-06-13T03:07:04+00:00

I somehow ran into the issue when I was working on an application that

  • 0

I somehow ran into the issue when I was working on an application that installs an assembly to GAC on demand (on click of a button), and tries to Assembly.Load it at the click of a next button or tries to invoke a method from that newly GAC-ed assembly, but fails. Problem and repro steps are below.

Problem and Repro Steps:
Create a new class library similar to the following named FooGreet.dll and strong name it. Let’s drag it to the assembly folder later.

namespace FooGreet
{
    public class Greeting
    {
        public string SayHello()
        {
            return "Hello";
        }
    }
}

Create a console application to load the above class library, similar to the following code.

namespace FooGreetCaller
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Press Enter to load assembly..");
            while (true)
            {
                string input = Console.ReadLine();
                if (input == "q" || input == "Q")
                    break;
                try
                {
                    System.Reflection.Assembly.Load("FooGreet, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=3f330bcf59df56c9");
                    Console.WriteLine("Assembly load success.");
                }
                catch (Exception eX)
                {
                    Console.WriteLine(eX.Message + Environment.NewLine + eX.StackTrace);
                }
            }
        }
    }
}
  1. Run the console applition:  Run an instance of the console application. Try to load the FooGreet.dll, you will get an exception with “Could not load file or assembly….”, no matter how many times you load. Don’t close the console window.
  2. Install FooGreet.dll to GAC:  Drag FooGreet.dll to GAC, on the same instance of the console application, try to load the FooGreet.dll again, you still get the same exception; which I call an anomaly because the FooGreet.dll is in the GAC, and the console application should have recognized it. Shouldn’t it have?
  3. Run a second instance of the console application:  Run a second instance of the console application. Try to load the FooGreet.dll, now the assembly is loaded fine.
  4. Uninstall FooGreet.dll from GAC:  Go to GAC, uninstall FooGreet.dll. Try loading the FooGreet.dll again in the second instance of the console application. The assembly is loaded successfully. Ideally, Shouldn’t it have thrown an exception like “Could not load file or assembly….”?

Question:
Questions are at step 2 and 4. And from the happenings at step 2 and step 4, it looks like when an application loads, it takes a snapshot of the GAC (at least with the default AppDomain, I haven’t tried creating and loading a new AppDomain). Is this true?

(In my app, as a workaround, I restart the application after I register the particular assembly to GAC with

System.EnterpriseServices.Internal.Publish().GacInstall(targetAssemblyName);

I am on a WinForms app and I am doing the restart in the Form_Load which causes the Main Form to flash for a fraction of a second.. which I dont like)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:07:05+00:00Added an answer on June 13, 2026 at 3:07 am

    Assembly Binder actually uses caching. Any assembly which is requested in code, Assembly Binder follows its process to load the assembly. The result of assembly binding is cached by the Assembly Binder. When the same assembly is requested again, Assembly Binder looks in the cache and if the assembly was loaded correctly, reference to the loaded assembly is returned, if the assembly bind failed, exception is returned.

    Another point to note that Binding Context is also used in caching. Assembly.Load, Assembly.LoadFrom and Assembly.Load(byte[]), these 3 methods uses 3 different binding contexts and caching is stored separately for each load type process. The recommended method however is Assembly.Load.

    To verify all of this, you can enable fusion on your machine and see the binding results in Assembly Binding Log Viewer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit complex to explain issue that I have ran into: I
Somehow this call to free() is not working. I ran this application on Windows
I ran into a particularly annoying issue. I have a LinqToSql project up and
Ok, so I've ran into a very strange issue, directly connected with before blocks.
I am new to C++ and ran into following supposedly bug, but somehow my
I ran into an issue. Below is my code, which asks user for input
I ran into a real head scratcher recently while trying to debug an issue
I have recently ran into this strange issue, I was trying to reference parent
Surfing the net I ran into Aquabrowser (no need to click, I'll post a
In developing my current app, I ran into some issues that I eventually traced

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.