Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Common repository for Class Libraries
Message
From
17/11/2005 11:16:26
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01069266
Message ID:
01069797
Views:
10
Pete,

It's not all that difficult ... perhaps the articles looked too complicated and you missed the underlying concept. Basically, you simply need to 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 a Outlook-style sidebar to launch all our modules and they are all loaded through Reflection.

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 (could take awhile, depending on how many DLLs you have). But, anyway, here's basically all you need:
// 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);
		}
	}
}
~~Bonnie



>Hello Bonny, thank's for your reply but I think the "smart client" route is a bit over the top for my needs, all I want to be able to do is have a central access point for certain classes - surely this must be doable more easily than sm ? thanks again
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform