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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:07:29+00:00 2026-06-11T22:07:29+00:00

I am working on some software that will dynamically build menu items for certain

  • 0

I am working on some software that will dynamically build menu items for certain dlls so that we can load components in dynamically based on what dlls are available on the users machine. Any dlls that I want to load have been flagged with an Assembly Attribute in the AssemblyInfo.cs file and how I determine whether or not I want to build a menu item for that dll. Here is my method so far:

private void GetReportModules() {
        foreach (string fileName in Directory.GetFiles(Directory.GetCurrentDirectory())) {
            if (Path.GetExtension(fileName) == ".dll" || Path.GetExtension(fileName) == ".exe") {
                System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(fileName);
                object[] attributes = assembly.GetCustomAttributes(typeof(ReportNameAttribute), false);
                if (attributes.Count() > 0) {
                    ReportNameAttribute reportNameAttribute = attributes[0] as ReportNameAttribute;
                    Type type = assembly.GetType(reportNameAttribute.BaseType);
                    MenuItem customReportsMenuItem = new MenuItem();
                    customReportsMenuItem.Header = reportNameAttribute.ReportName;
                    ReportsMenuItem.Items.Add(customReportsMenuItem);
                    customReportsMenuItem.Click += (s, ev) => {
                        var obj = Activator.CreateInstance(type);
                        type.InvokeMember("Show", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, obj, null);
                    };
                }
            }
        }
    }

For the most part its working fine, I am getting the dlls that I am expecting back out and am creating my menu items fine. The problem is that in order to check for the attribute I first need to load the assembly using Reflection. Some of the other local dlls are throwing errors when I try to load them about missing dependencies or he module was expected to contain an assembly manifest. Is there a way I can safely check to see if an assembly CAN be loaded before I actually do so? (sounds stupid as I write it out). Any thoughts on the problem I’m running into or better suggestions for how to accomplish what I’m trying here? Feeling a little bit in over my head.

  • 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-11T22:07:31+00:00Added an answer on June 11, 2026 at 10:07 pm

    You can create a separate AppDomain, try to load the assemblies there, send the results back, and unload the AppDomain. This way you do not change your current AppDomain with ‘garbage’ of any loaded assemblies.

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

Sidebar

Related Questions

I'm working on a Qt based software that involves some cryptography. The only three
I'm currently working on some .Net based software (.Net Framework 3.5 SP1) that integrates
I'm working on a software project for Emacs that has some tests that can
I'm working on some software to manage a device that communicates with a remote
I'm working on a script that is supposed to install some software from a
I'm working on a plugin for Avogadro (chemistry software) that uses pyqt. I've some
Working on some tweaks for a build script, I noticed that the output from
I am working on some software that should be used for a special type
I'm working on building a generic and reusable software license registration library that will
I'm working with some very old, monolithic software that is basically a heavily customized

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.