Very vague question on object-oriented design and VB.Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

(I'm not too comfortable with inheritance in VB and I don't think I've ever
read about a situation like this.)

Let's assume Dot Net 1.1 and VB.Net.

Let's assume a main Winforms program and a separate assembly that has an
abstract base class and an uncertain number of child classes (which in turn
may have children of their own.)

Now lets assume that the Winforms program instantiates these. Let's assume
the main program doesn't have much to do as far as instantiation is concerned
and I don't want to have to modify it every time I add a new child class to
the assembly.

What I would like to do is read off the list of available classes in the
assembly and possibly let the user select them from a popup list.

How might I go about doing this? Are there any good examples out there that
do this? (Is this even possible?)
 
B.

You are not the first who ask this question. What is the difference between
your solution from the view of the user than that he select them from a menu
and you instance them in your program in the normal ways.

When you want to overcome deployment, make than your menu class dynamicly
depending on a kind of config file.

For me this sounds as a question, "how can I drink from an open glas when I
have it upside down? It is not impossible however a lot of extras to do.

Just my thought,

Cor
 
Ctrl Alt J will open up the object browser, and you can find all the classes
in your assembly
 
Thanks to all who have replied.

Yes, I have wondered if Reflection might be of use and I will probably study
it some more. But I think my primary frustration is that there is no way to
declare a class without a literal.

To put it more clearly, what I would like to do is this:
dim x as New <variable containing a type selected by choice list>

....and so far as I know, that is impossible in VB.Net. Back to the drawing
board.

(Or am I forgetting something?)

rmacias said:
From what I understand, you are asking if you can get a list of avaliable
classes from an other assembly inside your windows app and then create an
instance of that class. Try using reflection by importing the
System.Reflection namespace. Take a look at the [Assembly].LoadFrom() method.

http://msdn.microsoft.com/library/d...ystemreflectionassemblyclassloadfromtopic.asp

B. Chernick said:
(I'm not too comfortable with inheritance in VB and I don't think I've ever
read about a situation like this.)

Let's assume Dot Net 1.1 and VB.Net.

Let's assume a main Winforms program and a separate assembly that has an
abstract base class and an uncertain number of child classes (which in turn
may have children of their own.)

Now lets assume that the Winforms program instantiates these. Let's assume
the main program doesn't have much to do as far as instantiation is concerned
and I don't want to have to modify it every time I add a new child class to
the assembly.

What I would like to do is read off the list of available classes in the
assembly and possibly let the user select them from a popup list.

How might I go about doing this? Are there any good examples out there that
do this? (Is this even possible?)
 
I'm afraid that reflection may be the only alternative. The following link
shows an example on how to dynamically create your type and then invoke it's
members. It takes a little work but it accomplishes what you want to do:

http://msdn.microsoft.com/library/d...tml/frlrfsystemtypeclassinvokemembertopic.asp

B. Chernick said:
Thanks to all who have replied.

Yes, I have wondered if Reflection might be of use and I will probably study
it some more. But I think my primary frustration is that there is no way to
declare a class without a literal.

To put it more clearly, what I would like to do is this:
dim x as New <variable containing a type selected by choice list>

...and so far as I know, that is impossible in VB.Net. Back to the drawing
board.

(Or am I forgetting something?)

rmacias said:
From what I understand, you are asking if you can get a list of avaliable
classes from an other assembly inside your windows app and then create an
instance of that class. Try using reflection by importing the
System.Reflection namespace. Take a look at the [Assembly].LoadFrom() method.

http://msdn.microsoft.com/library/d...ystemreflectionassemblyclassloadfromtopic.asp

B. Chernick said:
(I'm not too comfortable with inheritance in VB and I don't think I've ever
read about a situation like this.)

Let's assume Dot Net 1.1 and VB.Net.

Let's assume a main Winforms program and a separate assembly that has an
abstract base class and an uncertain number of child classes (which in turn
may have children of their own.)

Now lets assume that the Winforms program instantiates these. Let's assume
the main program doesn't have much to do as far as instantiation is concerned
and I don't want to have to modify it every time I add a new child class to
the assembly.

What I would like to do is read off the list of available classes in the
assembly and possibly let the user select them from a popup list.

How might I go about doing this? Are there any good examples out there that
do this? (Is this even possible?)
 
Thanks!

rmacias said:
I'm afraid that reflection may be the only alternative. The following link
shows an example on how to dynamically create your type and then invoke it's
members. It takes a little work but it accomplishes what you want to do:

http://msdn.microsoft.com/library/d...tml/frlrfsystemtypeclassinvokemembertopic.asp

B. Chernick said:
Thanks to all who have replied.

Yes, I have wondered if Reflection might be of use and I will probably study
it some more. But I think my primary frustration is that there is no way to
declare a class without a literal.

To put it more clearly, what I would like to do is this:
dim x as New <variable containing a type selected by choice list>

...and so far as I know, that is impossible in VB.Net. Back to the drawing
board.

(Or am I forgetting something?)

rmacias said:
From what I understand, you are asking if you can get a list of avaliable
classes from an other assembly inside your windows app and then create an
instance of that class. Try using reflection by importing the
System.Reflection namespace. Take a look at the [Assembly].LoadFrom() method.

http://msdn.microsoft.com/library/d...ystemreflectionassemblyclassloadfromtopic.asp

:

(I'm not too comfortable with inheritance in VB and I don't think I've ever
read about a situation like this.)

Let's assume Dot Net 1.1 and VB.Net.

Let's assume a main Winforms program and a separate assembly that has an
abstract base class and an uncertain number of child classes (which in turn
may have children of their own.)

Now lets assume that the Winforms program instantiates these. Let's assume
the main program doesn't have much to do as far as instantiation is concerned
and I don't want to have to modify it every time I add a new child class to
the assembly.

What I would like to do is read off the list of available classes in the
assembly and possibly let the user select them from a popup list.

How might I go about doing this? Are there any good examples out there that
do this? (Is this even possible?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top