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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:31:14+00:00 2026-05-23T20:31:14+00:00

I use MAF and I have a problem with activating the addin. Let me

  • 0

I use MAF and I have a problem with activating the addin. Let me explain my plan.

First I create a secondary AppDomain then I try to activate the addin:

MyAddIn = Token.Activate<AddInHostView>(domain);

My AddIn is very simple and referenced only one helper assembly. If this helper assembly is in the directory of the AddIn, all things work like a charm.

AddIns

  • MyDemoAddIn.dll
  • Helpers.dll

If I delete the Helpers.dll the whole application crash:

A first chance exception of type ‘System.IO.FileNotFoundException’ occurred in MyDemoAddIn.DLL
‘PresentationHost.exe’ (Managed (v4.0.30319)): Loaded ‘C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_de_b77a5c561934e089\mscorlib.resources.dll’
A first chance exception of type ‘System.Reflection.TargetInvocationException’ occurred in mscorlib.dll
A first chance exception of type ‘System.Reflection.TargetInvocationException’ occurred in System.AddIn.dll
A first chance exception of type ‘System.Reflection.TargetInvocationException’ occurred in System.AddIn.dll

I tested all things with exception handling. I can’t catch the exception from the Host, AddInView or my created AppDomain 🙁

Does anyone have an idea?

  • 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-23T20:31:14+00:00Added an answer on May 23, 2026 at 8:31 pm

    The answer is easier than you think… The problem was a error in the Finalizer() Method from the AddInView.dll which is an interlayer of the MAF. Here is my solution.

    Demo (Host)

    try
    {
        MyAddIn = Token.Activate<AddInHostView>(domain);
    }
    catch (Exception ex)
    {
        try
        {
            AppDomain.Unload(domain);
            domain = null;
        }
        catch (ThreadAbortException threadAbortException)
        {
            //ToDo: Logging
        }
        catch (CannotUnloadAppDomainException cannotUnloadAppDomainException)
        {
            //ToDo: Logging
        }
        catch (Exception exception)
        {
            //ToDo: Logging
        }
    }
    

    AddInView

    [AddInBase]
    public class AddInView : UserControl
    {
        //Necessary constructor to handle the exception.
        //Normal constructor is not called when an error occurs at startup!!!
        static AddInView()
        {
            AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;
        }
    
        //Normal constructor
        public AddInView()
        {
            //Do other things...
            //e.g. Dispatcher.UnhandledException += Dispatcher_UnhandledException;
        }
    
        static void CurrentDomain_DomainUnload(object sender, EventArgs e)
        {
            //To cleanup and stuff
        }
    }
    

    Now, if an error occurs (Activate<>) the exception handler catches the error (FileNotFound Helpers.dll not found) and unload the whole AppDomain without crash the main AppDomain 🙂

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

Sidebar

Related Questions

I want to use MAF in my project because I need a robust add-in
use this website a lot but first time posting. My program creates a number
use pthread_create to create limited number of threads running concurrently Successfully compile and run
Use Elixir and have two entities -- Voter and Candidate -- with many to
use javascript or other method ? have any recommendation?
Use case: You have 2-3 files displayed in your MacVim window(s). You press ctrl+Q
Use scenario is pretty simple: I have a desktop only application that could be
use case example I have a servlet that is receiving login requests. If a
USE Pooja GO ----Create TestTable CREATE TABLE TestTable(RtJobCode VARCHAR(20), RtProfCode smallint,RtTestCode smallint,ProfCode smallint,TestCode smallint)
Use: The user searches for a partial postcode such as 'RG20' which should then

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.