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

  • Home
  • SEARCH
  • 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 7723319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:24:47+00:00 2026-06-01T04:24:47+00:00

I am building a plugin-type system with each plugin represented as a DLL. I

  • 0

I am building a plugin-type system with each plugin represented as a DLL. I would like to be able to reload them without stopping the main application. This means that they must be loaded at runtime, without pre-built links between them (do a filesearch for dlls and load them). I have this set up using Assembly.LoadFile(filename), however, when I try to use File.Copy to replace the DLL it throws an exception, saying something akin to ‘file in use’. I have tried using AppDomain, loading all plugins through this secondary domain, and unloading it before reloading, but this throws the same exception.

My current code:

        if (pluginAppDomain != null)
            AppDomain.Unload(pluginAppDomain);
        foreach (string s in Directory.GetFiles(path_to_new_DLLs))
        {
            string name = s.Substring(s.LastIndexOf('\\') + 1);
            Console.WriteLine("Copying " + name);
            File.Copy(s, Path.Combine(current_directory, name), true); // Throws exception here
        }
        AppDomainSetup setup = new AppDomainSetup();
        setup.ApplicationBase = Environment.CurrentDirectory;
        setup.ShadowCopyFiles = "true"; 
        // I think this is where the problem is, maybe I'm forgetting to set something
        pluginAppDomain = AppDomain.CreateDomain("KhybotPlugin", null, setup);
        foreach (String s in Directory.GetFiles(Environment.CurrentDirectory, "*.dll"))
        {
            int pos = s.LastIndexOf('\\') + 1;
            Assembly dll = pluginAppDomain.Load(s.Substring(pos, s.Length - pos - 4));
            // Elided... Load types from DLL, etc, etc
        }
  • 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-01T04:24:48+00:00Added an answer on June 1, 2026 at 4:24 am

    Generally you need to unload the AppDomain for the communication.
    If you want to prevent the mentioned error you simply can load your dll by using Assembly.Load(Byte[]).

    You can also use the Managed Extensibility Framework which will save you a lot of work.

    Assembly.Load issue solution

    Assembly loaded using Assembly.LoadFrom() on remote machine causes SecurityException

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

Sidebar

Related Questions

I'm building a plugin assembly and I would like to provide an accompanying config
I'm building a plugin system for my application. I've read that anyone can decomple
I'm building a project that uses the JVCL plugin system, which relies on runtime
I'm exploring the idea of building a bridge between a DLL plugin for a
We're building a plugin for a commercial application that uses a recent version of
I'm building a plugin using Firebreath. I made a personal method in ABCPluginAPI.cpp called
There are several plugin options for building a search engine into your Ruby on
In eclipse, the m2eclipse plugin will prompt me for my credentials when I'm building
I'm using a maven plugin that defines a custom packaging type and lifecycle for
Edit: I would like to keep the infrastructure as is, so while the framework

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.