Click here to Skip to main content
16,005,181 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralCalling a callback address Pin
Ray Cassick10-Apr-04 9:55
Ray Cassick10-Apr-04 9:55 
GeneralRe: Calling a callback address Pin
Nick Parker10-Apr-04 11:07
protectorNick Parker10-Apr-04 11:07 
GeneralRe: Calling a callback address Pin
Ray Cassick11-Apr-04 6:30
Ray Cassick11-Apr-04 6:30 
GeneralRe: Calling a callback address Pin
Nick Parker11-Apr-04 7:57
protectorNick Parker11-Apr-04 7:57 
GeneralRe: Calling a callback address Pin
Ray Cassick11-Apr-04 8:09
Ray Cassick11-Apr-04 8:09 
GeneralRe: Calling a callback address Pin
Nick Parker11-Apr-04 8:26
protectorNick Parker11-Apr-04 8:26 
GeneralRe: Calling a callback address Pin
Ray Cassick11-Apr-04 8:30
Ray Cassick11-Apr-04 8:30 
GeneralRe: Calling a callback address Pin
Nick Parker12-Apr-04 9:23
protectorNick Parker12-Apr-04 9:23 
Here is a quick example in C# of some of the things you can do.

Load all assemblies based on a specified interface into a new AppDomain:
public AppDomain LoadAssemblies()
{
	AppDomain appdomain = AppDomain.CreateDomain("dynamic");
	string[] files = Directory.GetFiles(Environment.CurrentDirectory, "*.dll");
	if(files != null)
	{
		foreach(string file in files)
		{	
			Assembly a = Assembly.LoadFile(file);
			if(a != null)
			{
				Type[] types = a.GetTypes();
				foreach(Type t in types)
				{	
					Type[] interfaces = t.GetInterfaces();
					foreach(Type i in interfaces)
					{
                                                // Check for some type of interface
						if(string.Compare(i.ToString(), "IFun", true) == 0)
							appdomain.Load(file);
					}
				}
			}
		}
		
	}
	return appdomain;
}


You can then cycle through those assemblies register their event handlers that are define possibly by the interface I described in the previous post. The following is just an example of registering a few event handlers with an event.
using System;

namespace test
{
	class Class1
	{
		public delegate void RegisterEventHandler();
		public event RegisterEventHandler Register;
		
		public void fun()
		{
			Console.WriteLine("Hello from fun!");	
		}

		public void morefun()
		{
			Console.WriteLine("Hello from more fun!");
		}

		[STAThread]
		static void Main(string[] args)
		{
			Class1 c = new Class1();

			// Register new event handlers that match 
			// the appropriate delete method signature.
			c.Register += new RegisterEventHandler(c.fun);
			c.Register +=new RegisterEventHandler(c.morefun);

			// Confirm we have registered some events
			// and then fire event appropriatly.
			if(c.Register != null)
				c.Register();
		
			Console.Read();
		}
	} 
}


Hope this helps. Smile | :)

- Nick Parker
My Blog | My Articles

GeneralBuilding a program on top of another Pin
dnh50010-Apr-04 7:48
dnh50010-Apr-04 7:48 
GeneralRe: Building a program on top of another Pin
Dave Kreskowiak12-Apr-04 3:24
mveDave Kreskowiak12-Apr-04 3:24 
GeneralRe: Building a program on top of another Pin
dnh50012-Apr-04 4:06
dnh50012-Apr-04 4:06 
GeneralRe: Building a program on top of another Pin
Dave Kreskowiak12-Apr-04 6:47
mveDave Kreskowiak12-Apr-04 6:47 
QuestionHow to Determine which event fired Pin
gaxxx9-Apr-04 23:38
gaxxx9-Apr-04 23:38 
AnswerRe: How to Determine which event fired Pin
PaleyX10-Apr-04 2:20
PaleyX10-Apr-04 2:20 
GeneralRe: How to Determine which event fired Pin
gaxxx10-Apr-04 6:02
gaxxx10-Apr-04 6:02 
GeneralRe: How to Determine which event fired Pin
Ray Cassick11-Apr-04 6:33
Ray Cassick11-Apr-04 6:33 
GeneralRe: How to Determine which event fired Pin
gaxxx11-Apr-04 22:39
gaxxx11-Apr-04 22:39 
GeneralRe: How to Determine which event fired Pin
Dave Kreskowiak12-Apr-04 3:30
mveDave Kreskowiak12-Apr-04 3:30 
GeneralRe: How to Determine which event fired Pin
gaxxx12-Apr-04 8:55
gaxxx12-Apr-04 8:55 
GeneralRe: How to Determine which event fired Pin
Ray Cassick12-Apr-04 9:26
Ray Cassick12-Apr-04 9:26 
GeneralRe: How to Determine which event fired Pin
gaxxx12-Apr-04 10:03
gaxxx12-Apr-04 10:03 
GeneralRe: How to Determine which event fired Pin
Ray Cassick12-Apr-04 10:13
Ray Cassick12-Apr-04 10:13 
GeneralRe: How to Determine which event fired Pin
Dave Kreskowiak12-Apr-04 10:50
mveDave Kreskowiak12-Apr-04 10:50 
QuestionBook in VB.NET? Pin
Toola9-Apr-04 22:16
Toola9-Apr-04 22:16 
AnswerRe: Book in VB.NET? Pin
Sarvesvara (BVKS) Dasa11-Apr-04 1:05
Sarvesvara (BVKS) Dasa11-Apr-04 1:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.