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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:58:22+00:00 2026-06-12T21:58:22+00:00

In my MEF-based application, some modules use forms, but some do not. I want

  • 0

In my MEF-based application, some modules use forms, but some do not.

I want to be able to respond to the closure of these forms, but can’t seem to figure out how to do so. Module types are based on interfaces and those that use a form inherit a base class which inherits from Windows.Forms.Form.

E.g.

public partial class SwatchForm : ModuleForm, IAcquisition

Where

public partial class ModuleForm : Form

Since not all things that inherit IAcquisition (or my other module interfaces) inherit from ModuleForm, I tried this:

if (this.AcquisitionModule.GetType().IsSubclassOf(typeof(ModuleForm)))
{
    (ModuleForm)(this.AcquisitionModule).ModuleFormClosed += whatever....
}

But it still complains that IAcquisition has nothing called ModuleFormClosed.

I thought about using exceptions instead, but that feels like a bit of a hack. Is there a way to do this using events?

  • 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-12T21:58:23+00:00Added an answer on June 12, 2026 at 9:58 pm

    . has a higher precedence than a cast, so you need to place the parentheses differently. Furthermore, you can check the type in a simpler way. Try

    if (this.AcquisitionModule is ModuleForm) {
        ((ModuleForm) this.AcquisitionModule).ModuleFormClosed += ...
    }
    

    Another way is

    var moduleForm = this.AcquisitionModule as ModuleForm;
    if (moduleForm != null) {
        moduleForm.ModuleFormClosed += ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting to use MEF to build up a plugin based application, and I'm
I've an MEF application that works great when run locally, but doesn't work when
I'm developing a plugin based application using MEF and Asp.NET MVC 3 and I
I want to use MEF with asp.net mvc. I wrote following controller factory: public
I'm building a MEF-based plugin-centric WPF application and I'm facing an issue with GetExports,
I have a MEF (Microsoft Extension Framework) application which loads some assemblies from a
I have a console based MEF application the host ( CompositionContainer ) of which
I am converting a home-grown plugin architecture to .NET 4.0's MEF. The MEF-based application
I'm using MEF for a plugin-system to my application. The flow goes like this:
I'm working with MEF right now, but the answer I'm looking for probably is

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.