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 4337836
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:59:56+00:00 2026-05-21T10:59:56+00:00

So here is the situation: I have an assembly called Lib1.dll. For some reason

  • 0

So here is the situation:

I have an assembly called Lib1.dll. For some reason (not relevant to the question) I had to rename the assembly file name to Lib1New.dll, now while trying to load the renamed assembly using Assembly.LoadFile I noticed that the CLR tries to load the Lib1.dll as well.

If Lib1.dll is found in the search path it gets loaded in the address space. The application works fine irrespective of whether Lib1.dll was found or not. (The problem is that if Lib1.dll is found the file gets locked and can’t be deleted by other processes).

enter image description here

I don’t understand why the LoadFile searches and loads Lib1.dll. LoadFile is supposed to load the contents of an assembly file on the specified location, why is it searching for files.

MSDN documentation for LoadFile:

Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths. LoadFile does not load files into the LoadFrom context, and does not resolve dependencies using the load path, as the LoadFrom method does. LoadFile is useful in this limited scenario because LoadFrom cannot be used to load assemblies that have the same identities but different paths; it will load only the first such assembly.

  • 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-05-21T10:59:56+00:00Added an answer on May 21, 2026 at 10:59 am

    I suggest you try a simplification of your problem because I just tried to reproduce your situation and encountered no problem. I created a Lib.dll assembly, compiled it, created a console application that loaded it with LoadFile, then renamed Lib.dll and the Console’s reference to it to “LibNew.dll”. Then I re-compiled lib.dll and ran the console application. At that point I was unable to delete LibNew.dll, but I was able to delete Lib.dll.

    I suspect your Lib.dll may possibly be loading some information from its own assembly as it starts up, and is internally using another Load function to do so, which ends up finding the original Lib.dll. But if you have a very simple DLL, it wouldn’t do that extra load. My DLL has a function, which I was able to call, but I still saw my reported results above. Here’s my code:

    Console Application:

    class Program
    {
        static void Main(string[] args)
        {
            System.Reflection.Assembly assy = System.Reflection.Assembly.LoadFile(args[0]);
            Type class1 = assy.GetType("Lib.Class1");
    
            System.Reflection.MethodInfo myMethod = class1.GetMethod("MyMethod");
            Console.WriteLine(myMethod.Invoke(null, new object[] {"This is a string"}).ToString());
    
            Console.ReadLine();
        }
    }
    

    Lib:

    namespace Lib
    {
    public class Class1
    {
        public static string MyMethod(string param)
        {
            return "Fixed: [" + param.Replace(" ", "-") + "]";
        }
    }
    }
    

    Monitoring just LoadImage calls, I see that it did not try to load Lib.dll:
    Process Monitor Trace of LoadImage calls

    However, monitoring all events, I see that it did probe for Lib.dll in the application directory.
    Process Monitor Trace of all references to Debug\Lib

    Perhaps if you put the DLL in another directory you can force the behavior you want? It is strange behavior, though, considering the documentation.

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

Sidebar

Related Questions

Here's the situation I have a webpage which has one drop down called prefer.
Very odd situation here. For some reason I can't call 'Where', or any other
so, here is the situation here. I have 2 asp.net websites + some winform
Here is the situation : we have to offer a customer with a web-based
Here is my situation: I have one table that contains a list of drugs
here's the situation: I have a where in every cell all the area has
Here is my situation: I have a C project linking with many libraries (I
Here's the situation: I have a two images that are over 1024 in width
Here is the situation: You have one long-running calculation running in a background thread.
I have an situation here that looks very like a SELECT N+1 from the

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.