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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:42:58+00:00 2026-05-27T04:42:58+00:00

I was just wondering what happens if I was to load the same assembly

  • 0

I was just wondering what happens if I was to load the same assembly bytes twice within a web app.

For example I have this code

byte[] assem = System.IO.File.ReadAllBytes(appRoot + "/Plugins/Plugin.dll");

var loadedAssem = Assembly.Load(assem);

var plugin = loadedAssem.CreateInstance("Plugin.ThePlugin") as IPlugin;

I ran this code and on the first request I assume it would load the assembly into ram ( or the http runtime appdomain? ) and then I can create instances of whatever is in there.

If I ran this code again, say on the second request what would happen to the assembly on the first request?

Would is still exist in ram? if so how does it differentiate between the two assemblies? or does it overwrite the previously declare classes?

This is for my understanding, as like I do in PHP its not just a case of “require_once”.

  • 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-27T04:42:59+00:00Added an answer on May 27, 2026 at 4:42 am

    This will load two distinct copies of the assembly, each of which can be used from your application. The types in each assembly are distinct types and will not inter-operate with one-another. For instance, if you take a Widget from Copy1 and try to pass it to a method that takes a Widget on Copy2, this will cause a runtime failure. It is not possible to unload assemblies once they have been loaded in this way (i.e. into your main AppDomain.)


    Regarding instantiation:

    • If you use Assembly.CreateInstance (as shown in your post), this will create it from the Assembly instance you used to make the call.
    • If you use an Activator.CreateInstance that takes a string, you need to specify the assembly name. Since both loaded assemblies will have the same name in this case, it will use assembly resolution rules, which, I think by default, will favor the first match (so the assembly you loaded first.) I’m not certain of this. You can hook the AppDomain.AssemblyResolve event to provide your own prioritization and make it use your most-recently-loaded assembly.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering why this certain problem happens to me. If you can
Hello I was just wondering how this line of code works (it has been
just wondering if there is a way to reduce the amount of code needed
Just wondering, having the following simple code: var object1 = { name: function (){
just wondering when I had an iphone I was able to create a web
Just wondering is it possible to build CLI app that can be run from
Just wondering if anyone can optimize this usortMonths() function to be better? Basically I
I'm just playing around with some PHP and was wondering what happens when an
I'm just wondering what happens in the case of a time zone changing, when
I was wondering what happens if from the kernel (Linux in this case) you

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.