473,782 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Load of Assembly - Event-Handler ???

Hi all,

I've an OL-Style App loading MDIChild-Windows (Panes) on demand dynamicaly
at runtime.
Loading the Forms works fine but establishing an EventHandler (to receive
information from
the loaded Panes by the Container) fails with the Message "Cannot bind to
...." in the line where
the Delegate should be created.

The Sub should load the Assembly (WinForm) and establish an EventHandler to
the local Sub
"PlugInRequestB roker" which would handle the requested Action.

Has anyone an idea how the Event-Handle could be established (my first Try:
AddHandler ...
did not work).

Thx for any help!
Stefan Rosenthal

The Event is declared in an Interface which is implemented by the loaded
Assembly/Form.
The Sub "PlugInRequestB roker" is declared in the same class as
"LoadPaneFromAs sembly"
(in the MDIParent).

Code Snippet:

Private Function LoadPaneFromAss embly(ByVal pFile As String, ByVal pType As
String) As Object

Dim objPane As Object
Dim objAssembly As System.Reflecti on.Assembly
Dim objType As Type

Try
objAssembly = System.Reflecti on.Assembly.Loa dFrom(pFile)
objType = objAssembly.Get Type(pType)
objPane = System.Activato r.CreateInstanc e(objType)

' Event-Handler für Request-Event installieren
Try
Dim requestEvent As System.Reflecti on.EventInfo = _
objType.GetEven t("Request")
Dim eventHandlerInf o As System.Reflecti on.MethodInfo = _
Me.GetType.GetM ethod("PlugInRe questBroker")
Dim eventHandlerTyp e As System.Type = _
requestEvent.Ev entHandlerType
Dim requestDelegate As System.Delegate = _
System.Delegate .CreateDelegate (eventHandlerTy pe,
eventHandlerInf o, "PlugInRequestB roker") <= Failure !!!
requestEvent.Ad dEventHandler(M e, requestDelegate )
Catch ex As Exception
MsgBox(ex.Messa ge)
End Try

Catch ex As Exception
objPane = Nothing
MsgBox("Error in LoadPaneFromAss embly: " & ex.Message)
End Try

Return objPane

End Function
Nov 21 '05 #1
0 1684

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

Similar topics

2
2133
by: John Smith | last post by:
I have created an assembly that needs to load types from other assemblies on-the-fly. However, if I use the Assembly.Load() method it tells me it cannot find the assembly that I requested. I assume this is because the assembly is not referenced in the project. So how do I load assemblies that are in my Visual Studio solution but are not referenced in the particular project? Thanks
2
20922
by: Stelios | last post by:
Does anyone know how to dynamically load an assembly from a location other that the working directory by using Assembly load method. It is important to use the specific method because is the method used by CLR to enforce version and security checking. I have try by changing the appdomain APPBASE property but is not working and i am wondering weather I am doing something wrong. The code I use is the following
9
4494
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the "Let Users Add Functionality to Your .NET Applications with Macros and Plug-Ins" article at MSDN for the dynamic loading of DLLs http://msdn.microsoft.com/msdnmag/issues/03/10/Plug-Ins/default.aspx
8
2548
by: Eyeawanda Pondicherry | last post by:
I have put some code together that creates an enum dynamically from some database values. The enum can be read perfectly by an application that references the dynamically generated dll. If I /emit/ a new version of the assembly, and start the application again, the new values will appear for the enum. However, suppose I want the application to remain in a running state.
6
1228
by: JonS. | last post by:
Hi, I'm trying to create a Windows Forms portal application and need some help. What I currently have is a main application (.exe) containing an MDI form. The idea is that this main application loads forms from packages (i.e. DLLs containing one or more forms). The trick is that I'd like the form packages and forms loaded to be dynamic. Therefore the main application should be able to "discover" all the form packages, then allow those...
2
3067
by: Matt | last post by:
I'm hoping someone can steer me in the right direction to try to do the following: I am developing an application where we receive files from customers. Right now we receive a variety of formats. I was looking at writing some type of base application that would allow me to add-in either new assemblies or plugins, don't know how or which way, for different scenarios. We may just recieve a text file so an assembly would handle...
3
5128
by: dhnriverside | last post by:
Hi guys I'm writing a console app in C# for which i want to enable the user to have several "plug-ins". The app has a switch to set the plug-in to use, and at runtime the required dll is loaded and executed. I had thought I could do this with a C# class compiled, and just load the relevant dll file for the class we want, and call it as normal. Of course this won't work because C# class files need to be compiled into the app? Correct?
1
7588
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
3
3986
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
8
2021
by: George Meng | last post by:
I got a tough question: The backgroud for this question is: I want to design an application works like a engine. After release, we can still customize a form by adding a button, and source code for the button. (This is done by the form itself, not by using VS.Net) (button and source code should be a record in database, these information should be retrieve from database when the form shows up) What I want is:
0
9641
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.