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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:39:44+00:00 2026-05-19T01:39:44+00:00

This might be a doozy for some. I’m not sure if it’s even 100%

  • 0

This might be a doozy for some. I’m not sure if it’s even 100% implementable, but I wanted to throw the idea out there to see if I’m really off of my rocker yet.

I have a set of classes that mimics enums (see my other questions for specific details/examples). For 90% of my project, I can compile everything in at design time. But the remaining 10% is going to need to be editable w/o re-compiling the project in VS 2010. This remaining 10% will be based on a templated version of my Enums class, but will generate code at runtime, based upon data values sourced in from external configuration files.

To keep this question small, see this SO question for an idea of what my Enums class looks like. The templated fields, per that question, will be the MaxEnums Int32, Names String() array, and Values array, plus each shared implementation of the Enums sub-class (which themselves, represent the Enums that I use elsewhere in my code).

I’d ideally like to parse values from a simple text file (INI-style) of key/value pairs:

[Section1]
Enum1=enum_one
Enum2=enum_two
Enum3=enum_three

So that the following code would be generated (and compiled) at runtime (comments/supporting code stripped to reduce question size):

Friend Shared ReadOnly MaxEnums As Int32 = 3

Private Shared ReadOnly _Names As String() = New String() _
    {"enum_one", "enum_two", "enum_three"}

Friend Shared ReadOnly Enum1 As New Enums(_Names(0), 1)
Friend Shared ReadOnly Enum2 As New Enums(_Names(1), 2)
Friend Shared ReadOnly Enum3 As New Enums(_Names(2), 4)

Friend Shared ReadOnly Values As Enums() = New Enums() _
    {Enum1, Enum2, Enum3}

I’m certain this would need to be generated in MSIL code, and I know from reading that the two components to look at are CodeDom and Reflection.Emit, but I was wondering if anyone had working examples (or pointers to working examples) versus really long articles. I’m a hands-on learner, so I have to have example code to play with.

Thanks!

  • 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-19T01:39:44+00:00Added an answer on May 19, 2026 at 1:39 am

    You can use the Compiler Class to compile the code into a dll. Then just dynamically load the assembly at run-time.

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

Sidebar

Related Questions

This might be a god awful question but I'm not sure why it won't
This might be a trivial question for some, but I could not find the
This might seem like a very easy question for some of you folks, but
This might be a trivial question for some erlang veterans but it would be
This might be an easy question, but I cannot figure out why the compiler
This might be a super easy answer, since I'm sure it's not uncommon. I
This might seem as child play, but I can't figure out how I can
This might be deleted, since involves idea sharing which is not quite allowed in
This might seem like a n00b question, but I am trying to break some
This might be small question but I am not able to find answer 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.