473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Dynamically Loading Programs

Our company wants to standardize all our new programs. We are using .NET
2.0 and VB.NET against an Oracle Database and SQL Server Database. One
suggestion was to have a single sign on and based on the sign on, list the
programs available to the user. The user would select the program they want
and it would load the program for them in like an MDI application. I would
like to make this like an MDI form that has a Shell application that
controls the login and display of the programs. The shell application would
have a tool strip and status strip that would apply to all programs. Then
in the shell program display the program. Can this be done with an MDI
program? Any help (documentation ,example etc) would be great. I want to
jump on this ASAP so we aren't doing programs piece meal. Thanks.

John
Mar 28 '06 #1
2 976
BK
Not sure if this will help, but....

I had a need to display options to the user in a tree control. The
available programs (forms) were determined by a security application so
at run time, I didn't know what items may or may not be listed on the
menu tree.

To avoid a very lengthy case/select statements that would need to be
modified everytime I added a new form, I used reflection to solve my
problem.

My wife just called, she's out front waiting for me (we carpool). IF
this sounds like something that might help you, let me know and I'll
share the few lines of code necessary to make this happen.

Bill

Mar 28 '06 #2
BK
Ok, here is the pertinent code:

Private Sub InstantiateObject(ByVal FullName As String, ByVal
Container As String, ByVal ObjectName As String)
Try
Dim ExternalAssembly As System.Reflection.Assembly = _
System.Reflection.Assembly.LoadFrom(Container)
Dim CalledForm As BravoBaseForm = _
ExternalAssembly.CreateInstance(FullName, True)
CalledForm.Name = ObjectName
Me.FormOwner.AddOwnedForm(CalledForm)
CalledForm.FormUser = Me.MenuUser
CalledForm.FriendlyFormName = FullName
CalledForm.Show()
Catch ex As Exception
Dim ErrorMessageText As String
ErrorMessageText = "Error attempting to run this Option,
contact Software Support" & vbCrLf & _
vbCrLf & "Menuhandler::InstantiateObject" & vbCrLf & _
"Object FullName = " & FullName.Trim & " Container = "
& Container.Trim & _
vbCrLf & "Message: " & ex.Message
Me.MenuUser.BravoMessage.HandleMsg(ErrorMessageTex t, 2)
Me.MenuUser.BravoMessage.HandleMsg(ex.Message, True)
End Try
End Sub

A few things to know/consider. All my forms in this application are
derived ultimately from BravoBaseForm, so I use that as a template to
receive the results of ExternalAssembly.CreateInstance. You could
easily modify this to adapt to other object types.

FullName is the fully qualified name of the object.
Container is the assembly name (usually Exe, but could be a dll)
ObjectName is a unique reference to the form as used in the database
and as a unique id for the running form (we don't allow a form to be
open more than once, you could adjust this pretty easily).

Here is how these parts fit together:

If I have an assembly that compiles as Foo.Exe and there is a form
named FindWidgets.Vb and it is listed in my security table with a
unique id of FindWidget, then I'd call this function as follows:

InstantiateObject("Foo.FindWidgets", "Foo.Exe", "FindWidget")

The heavy lifting in this function is these two lines:

Dim ExternalAssembly As System.Reflection.Assembly = _
System.Reflection.Assembly.LoadFrom(Container)
Dim CalledForm As BravoBaseForm = _
ExternalAssembly.CreateInstance(FullName, True)

The first one basically creates a pointer to the Assembly, Foo.Exe in
my example (Ok, I know there aren't really pointers in .NET, but I'm
old school). The second line drills into the assembly and creates an
instance of the class named Widgets.Vb in my example.

Hopefully this helps!

I'm sending a reply to your email and also posting it in the group for
others to use.

Bill

Mar 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
3
by: h4nne5 | last post by:
hi! i would like to create a website where you can browse really high definition images of mine. they are huge and loading them as one would take ages and would probably give some problems to the...
6
by: Dan Dorey | last post by:
I actually have two questions here, but I'll start by giving an outline of what I'm trying to do. I'm building an app with a simple plugin architecture (all in the same app domain). I have each...
2
by: A.Wussow | last post by:
Hi Everybody, i want to load dynamically content from some user controls (with forms, or some data-controls) using atlas. So i use an UpdatePanel for loading the user control into a placeholder....
1
by: Bob Rock | last post by:
Hello, I'm new to ASP.NET and I've been looking into the topic of dynamically loading (typically accomplished with a LoadControl followed by a MyControl.Controls.Add()) both user controls and...
36
by: Martin Larsen | last post by:
Hi, When a PHP program links to a library using include or require (or their _once variations), is the library then linked dynamically or statically? While it might seem irrelevant from a...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
20
by: Nickolai Leschov | last post by:
Hello all, I am programming an embedded controller that has a 'C' library for using its system functions (I/O, timers, all the specific devices). The supplied library has .LIB and .H files. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.