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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:32:37+00:00 2026-05-23T00:32:37+00:00

I am making a component based system (each object delegates all functionality to a

  • 0

I am making a component based system (each object delegates all functionality to a variety of components which can be added at runtime) and want to be able to define my objects in XML files for ease. I know how to use Activator.CreateInstance to create my objects from strings, but I require full classnames and assembly names.

The issue comes from the fact that these components may be either pre-built in my library (say assembly FirstAssembly.dll and namespace Foo.Bar) or defined specifically for my game (say assembly SecondAssembly.dll and namespace Second.Blah).

//In some assembly FirstAssembly.dll

namespace Foo.Bar
{
class SomeClassA
{
}

class SomeClassB
{
}
}

//In some assembly SecondAssembly.dll

namespace Second.Blah
{
class SomeClassC
{
}

class SomeClassD
{
}
}

//In my XML..I would much prefer
<class="SomeClassA"...> </class>
<class="SomeClassD"...> </class>

//Over this, which would just need to check FirstAssembly and SecondAssembly and error handle
<class="Foo.Bar.SomeClassB"...></class>
<class="Second.Blah.SomeClassD"...></class>

//Which I would much prefer over
<class="Foo.Bar.SomeClassB" assembly="FirstAssembly"...></class>
<class="Second.Blah.SomeClassD" assembly="SecondAssembly"...></class>

The last solution would be easy, if rather annoying – I need assembly names, or at least some way of saying ‘component from library’ or ‘component from game’.

The second solution is probably easier – I just need (some way) of checking – probably just try/catch – if the class is in FirstAssembly; if not, try SecondAssembly.

The first solution is what I really want to do, but I do not think it possible. The amount of namespaces would make it difficult.

tl;dr Is there a way I can make this system work so my XML files look as close to the first solution as possible? If not, is the second solution viable?

  • 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-23T00:32:37+00:00Added an answer on May 23, 2026 at 12:32 am

    It sounds like you want something like:

    Type targetType = (from assembly in candidateAssemblies
                       from type in assembly.GetTypes()
                       where type.Name == nameFromXml
                       select type).FirstOrDefault();
    

    Note that:

    • If there are multiple matches, this will just return the first one.
    • If there are no matches, this will return null
    • You may wish to add extra conditions, such as public types etc
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a 2D game I'm making (for Android) I'm using a component-based system where
I'm making a component based entity system for a game engine. I have an
We have an 'enterprisey' system with a scheduling component which gets floored if any
I'm making a small web application in Seaside. I have a login component, and
I have a Windows.Forms component which has a mySize property that returns a Size
Question Can I build a image database/library that has an e-commerce style checkout system
I'm making a custom slider component. The head (the thing that you drag) is
I am venturing into making my own components in Delphi. I'm having difficulty getting
I am making a SQL script editor / executor component for my application, very
I am busy making a Joomla! component. And know i want to link to

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.