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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:13:42+00:00 2026-06-11T12:13:42+00:00

I am creating an uninstall utility in C#. The utility will unregistered the files

  • 0

I am creating an uninstall utility in C#. The utility will unregistered the files registered through Regasm and then it will delete those files.

Assembly asm = Assembly.LoadFrom("c:\\Test.dll")
int count = files.Length;
RegistrationServices regAsm = new RegistrationServices();
if (regAsm.UnregisterAssembly(asm))
MessageBox.Show("Unregistered Successfully");

The above code works fine but when i try to delete Test.dll, error appear and cannot delete it.
What i have understand that Assembly.LoadFrom(“c:\Test.dll”), has save the reference to this file and it is not losing it. Is there any way to resolve this issue?

Thanks and Regards

  • 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-11T12:13:43+00:00Added an answer on June 11, 2026 at 12:13 pm

    You need to load the type in another appdomain. Typically this is done by loading a type derived from MarshalByRefObject into another domain, marshaling the instance to the original domain and executing the method via proxy. It sounds harder then it is so here is the exampe:

    public class Helper : MarshalByRefObject // must inherit MBRO, so it can be "remoted"
    {
        public void RegisterAssembly()
        {
          // load your assembly here and do what you need to do
          var asm = Assembly.LoadFrom("c:\\test.dll", null);
          // do whatever...
        }
    }
    
    static class Program
    {
        static void Main()
        {
          // setup and create a new appdomain with shadowcopying
          AppDomainSetup setup = new AppDomainSetup();
          setup.ShadowCopyFiles = "true";
          var domain = AppDomain.CreateDomain("loader", null, setup);
    
          // instantiate a helper object derived from MarshalByRefObject in other domain
          var handle = domain.CreateInstanceFrom(Assembly.GetExecutingAssembly().Location, typeof (Helper).FullName);
    
          // unwrap it - this creates a proxy to Helper instance in another domain
          var h = (Helper)handle.Unwrap();
          // and run your method
          h.RegisterAssembly();
          AppDomain.Unload(domain); // strictly speaking, this is not required, but...
          ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a server-side socket will fail if I'm trying to use the same port
I'm creating a windows insaller for app that wll write some files to home
For some reason my eclipse/android development environment has stopped creating the r.java files and
Creating a rating system and the info is not being transmitted through my $_GET
System Info: Mac OSX 10.7, Python 2.6.7, Plone 4.0.7 I'm creating an uninstall profile
I am working on creating a python script to find Installed programs in Uninstall
Creating an HTA that will automate the installation of several applications it starts by
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
Creating an a app, where I store bunch of photos in the drawable folder,
Creating liquid layouts is an immense pain. Now, I totally understand that tables should

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.