Loading applications at runtime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • joannax

    #1

    Loading applications at runtime

    Hi,
    I am an experienced programmer in several languages, but new to VB .NET. I
    am designing an application which consists of a single "menu" program/form
    that selectively transfers control to several other programs/forms. This is
    straightforward when all the forms are in one assembly. But I need this to
    be modular and dynamic so that each program loaded can be in its own .exe and
    the central program can load and execute it then regain control when the
    called program is done. I've tried "process.st art" but I feel there must be
    a better way, especially since I'd like to be able to communicate information
    between the controller and the satellite applications.
    Important point is that the controller will be designed so that it doesn't
    know beforehand which programs are installed and can be called.
    Also, there is some communication with a server by all the programs, but the
    classes involved do not need to be shared if this cannot be done.
    In other languages there is an external call, load or "chain" mechanism for
    resolving references at runtime. Can this be done in VB .NET?

    Thanks for any help.
    --
    Joanna
  • ..:: Kevin ::..

    #2
    RE: Loading applications at runtime

    Joanna,

    I am currently working on a project where we have done pretty much what you
    are trying to do. Our project consists of an exe that acts as the shell, and
    all the modules that slot into this shell are developed as DLL's with user
    controls in them.

    The way we have tackled the problem was to make the controls in our DLL
    implement an interface that we defined. The interface itself is pretty
    basic, and it just has a few details in there such as the controls display
    name.

    The shell searches a specified directory on startup that contains all of our
    dll's. The shell then loads each dll in turn into an assembly and loops
    through the types collection looking for items that implement our defined
    interface. Once it has found a match we use reflection to get some
    information out of the control and add it to a menu.

    When a menu item is clicked, we use the information we stored to load the
    control via reflection and display it in our shell program.

    Using this method, we have made the shell application completly seperate
    from our modules, all it requires is that the module implements our defined
    interface.

    We have also used a custom implementation of an observer pattern so that the
    modules can communicate with the shell.

    I hope this is of some help or at least pointed you in the right direction
    of where to start looking for more information?

    Kevin

    "joannax" wrote:
    [color=blue]
    > Hi,
    > I am an experienced programmer in several languages, but new to VB .NET. I
    > am designing an application which consists of a single "menu" program/form
    > that selectively transfers control to several other programs/forms. This is
    > straightforward when all the forms are in one assembly. But I need this to
    > be modular and dynamic so that each program loaded can be in its own .exe and
    > the central program can load and execute it then regain control when the
    > called program is done. I've tried "process.st art" but I feel there must be
    > a better way, especially since I'd like to be able to communicate information
    > between the controller and the satellite applications.
    > Important point is that the controller will be designed so that it doesn't
    > know beforehand which programs are installed and can be called.
    > Also, there is some communication with a server by all the programs, but the
    > classes involved do not need to be shared if this cannot be done.
    > In other languages there is an external call, load or "chain" mechanism for
    > resolving references at runtime. Can this be done in VB .NET?
    >
    > Thanks for any help.
    > --
    > Joanna[/color]

    Comment

    • Mattias Sjögren

      #3
      Re: Loading applications at runtime

      [color=blue]
      >Can this be done in VB .NET?[/color]

      Sure, what you describe is a typical plugin based architecture. If you
      google for something like "VB.NET plugin" I think you'll find plenty
      of examples. A good start is reading about the Asseembly.Load (and
      LoadFrom) methods in the docs.



      Mattias

      --
      Mattias Sjögren [MVP] mattias @ mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      Comment

      • joannax

        #4
        RE: Loading applications at runtime

        Kevin,

        Your note is certainly helpful, and I will try the concept. I was looking
        for a simpler solution since each satellite application could really be run
        stand-alone under certain conditions, which is why I wanted to have these in
        ..exe format. On the other hand, "process.st art" is not ideal because the
        applications are all created in the .NET framework and some parameter passing
        is required; also, they do use some of the same dll's. This makes your idea
        of using reflection much closer to my scenario.
        I am considering using "AppDomain" -- ExecuteAssembly for transfer of
        control, and [Get/Set]Data for passing parameters. Have you used these at
        all?
        Will get back after I've tried.

        Thanks again.
        --
        Joanna


        "..:: Kevin ::.." wrote:
        [color=blue]
        > Joanna,
        >
        > I am currently working on a project where we have done pretty much what you
        > are trying to do. Our project consists of an exe that acts as the shell, and
        > all the modules that slot into this shell are developed as DLL's with user
        > controls in them.
        >
        > The way we have tackled the problem was to make the controls in our DLL
        > implement an interface that we defined. The interface itself is pretty
        > basic, and it just has a few details in there such as the controls display
        > name.
        >
        > The shell searches a specified directory on startup that contains all of our
        > dll's. The shell then loads each dll in turn into an assembly and loops
        > through the types collection looking for items that implement our defined
        > interface. Once it has found a match we use reflection to get some
        > information out of the control and add it to a menu.
        >
        > When a menu item is clicked, we use the information we stored to load the
        > control via reflection and display it in our shell program.
        >
        > Using this method, we have made the shell application completly seperate
        > from our modules, all it requires is that the module implements our defined
        > interface.
        >
        > We have also used a custom implementation of an observer pattern so that the
        > modules can communicate with the shell.
        >
        > I hope this is of some help or at least pointed you in the right direction
        > of where to start looking for more information?
        >
        > Kevin
        >
        > "joannax" wrote:
        >[color=green]
        > > Hi,
        > > I am an experienced programmer in several languages, but new to VB .NET. I
        > > am designing an application which consists of a single "menu" program/form
        > > that selectively transfers control to several other programs/forms. This is
        > > straightforward when all the forms are in one assembly. But I need this to
        > > be modular and dynamic so that each program loaded can be in its own .exe and
        > > the central program can load and execute it then regain control when the
        > > called program is done. I've tried "process.st art" but I feel there must be
        > > a better way, especially since I'd like to be able to communicate information
        > > between the controller and the satellite applications.
        > > Important point is that the controller will be designed so that it doesn't
        > > know beforehand which programs are installed and can be called.
        > > Also, there is some communication with a server by all the programs, but the
        > > classes involved do not need to be shared if this cannot be done.
        > > In other languages there is an external call, load or "chain" mechanism for
        > > resolving references at runtime. Can this be done in VB .NET?
        > >
        > > Thanks for any help.
        > > --
        > > Joanna[/color][/color]

        Comment

        Working...