A lot of the reading I've done in the past concerning Smart Client applications is a bit daunting.
Most of the articles looked too complicated and it's easy to miss the underlying concept.
Basically, all you need to do is simply use the Assembly.LoadFrom method from the System.Reflection class to load your DLLs.
It's as simple as that.
Ideally, you should architect your application so that there is a small, lightweight executable installed on the client machine.
This executable need not contain much in the way of core logic. Ideally, it just references the DLLs it needs,
which reside out on a remote Web server and which supply all of the necessary application logic. We use an Outlook-style
sidebar in our application to launch all our modules and they are all loaded through Reflection. The DLLs will only be
downloaded from the server if they are newer versions, otherwise the version already on the client will be the one loaded.
If you haven't architected your application that way to begin with, you could add something to your app to do it
after the fact (how you implement this is up to you ... you could have a special form that requires the user to
start the download process, or you could do it automatically every time you start the app (which could take awhile,
depending on how many DLLs you have). But, anyway, here's basically all you need to get you thinking:
// First, an ArrayList containing the filename of all your DLLs.
// This can be a class, as shown below, or simply a property
public class AssembliesList : ArrayList
{
public AssembliesList()
{
this.Add("MyMainControl.DLL");
this.Add("MyBusiness.DLL");
this.Add("SomeOtherOnes.DLL");
}
}
// Next, the method that actually does the work:
private void DownloadAssemblies()
{
string URL = GetTheURLWhereYourAssembliesAreLocated();
string DLL;
AssembliesList oList = new AssembliesList();
for (int i = 0; i < oList.Count; i++)
{
DLL = oList[i].ToString().Trim();
try
{
System.Reflection.Assembly o =
System.Reflection.Assembly.LoadFrom(URL + DLL);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
from a solution provided by Bonnie Berent in Message #1069797
|