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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:36:54+00:00 2026-05-14T21:36:54+00:00

I have written an application that unit tests our hardware via a internet browser.

  • 0

I have written an application that unit tests our hardware via a internet browser.

I have command classes in the assembly that are a wrapper around individual web browser actions such as ticking a checkbox, selecting from a dropdown box as such:

BasicConfigurationCommands
EventConfigurationCommands
StabilizationCommands

and a set of test classes, that use the command classes to perform scripted tests:

ConfigurationTests
StabilizationTests

These are then invoked via the GUI to run prescripted tests by our QA team. However, as the firmware is changed quite quickly between the releases it would be great if a developer could write an XML file that could invoke either the tests or the commands:

<?xml version="1.0" encoding="UTF-8" ?> 
<testsuite>
    <StabilizationTests>
        <StressTest repetition="10" />
    </StabilizationTests>
    <BasicConfigurationCommands>
        <SelectConfig number="2" />
        <ChangeConfigProperties name="Weeeeee" timeOut="15000" delay="1000"/>
        <ApplyConfig />
    </BasicConfigurationCommands> 
</testsuite>

I have been looking at the System.Reflection class and have seen examples using GetMethod and then Invoke. This requires me to create the class object at compile time and I would like to do all of this at runtime.

I would need to scan the whole assembly for the class name and then scan for the method within the class.

This seems a large solution, so any information pointing me (and future readers of this post) towards an answer would be great!

Thanks for reading,

Matt

  • 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-14T21:36:54+00:00Added an answer on May 14, 2026 at 9:36 pm

    To Find all classes in an assembly:

    public Type FindClass(string name)
    {
       Assembly ass = null;
       ass = Assembly.Load("System.My.Assembly"); // Load from the GAC
       ass = Assembly.LoadFile(@"c:\System.My.Assembly.dll"); // Load from file
       ass = Assembly.LoadFrom("System.My.Assembly"); // Load from GAC or File
    
       foreach(Type t in ass.GetTypes())
       {
          if (t.Name == name)
             return t;
       }
    
       return null;
    }
    

    In reality you should tag your class with an attribute, it makes them more discoverable.

    To instantiate an instance of said class:

    public T Instantiate<T>(Type typ, object[] arguments)
    {
        return (T)Activator.CreateInstance(typ, arguments, null);
    }
    

    Don’t forget, you should probably wrap these with appropriate try/catch blocks

    Then to find a method on a class

    Type t = FindClass("MyType");
    MethodInfo meth = t.GetMethod("TestSomething", typeof(string), typeof(int)); // finds public ??? TestSomething(string, int)
    

    Just play around with the Object Browser in VStudio and learn the Reflection classes, there’s lots you can do.

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

Sidebar

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.