Suppose I have object O with an event E that are
defined in an assembly M that I am referencing in
my code via reflection. M also defines object A which
is an argument to E.
At compile-time, how can I write a function that meets
the signature for event E, when the compiler
doesn't know about A ?
I can solve this problem using Delegate.Create Delegate
etc if the type of E's arguments are known at
compile time, but what about when there is an
unknown type ?
TIA,
Stephen 3 1552
U¿ytkownik "Stephen Ahn" <noaddress> napisa³ w wiadomo¶ci
news:OW******** ******@tk2msftn gp13.phx.gbl... Suppose I have object O with an event E that are defined in an assembly M that I am referencing in my code via reflection. M also defines object A which is an argument to E.
At compile-time, how can I write a function that meets the signature for event E, when the compiler doesn't know about A ?
I can solve this problem using Delegate.Create Delegate etc if the type of E's arguments are known at compile time, but what about when there is an unknown type ?
You could read the E's signature at run-time, create a handler code
dynamically (as string), compile it to memory (adding a reference to M) and
create a delegate handler from compiled method.
But since you do not know anything about the delegate's argument type, how
would you like to make use of it?
regards,
Wiktor Zychla
"Wiktor Zychla" <us**@nospam.co m.eu> wrote in message
news:OY******** *****@tk2msftng p13.phx.gbl... You could read the E's signature at run-time, create a handler code dynamically (as string), compile it to memory (adding a reference to M) and create a delegate handler from compiled method.
But since you do not know anything about the delegate's argument type, how would you like to make use of it?
Thanks for your response.
Well, the argument type is a simple class with just a few public properties.
The types of the properties are standard dotnet types.
Since we know the names of the properties, I was thinking
they could be referenced via reflection.
We had to use reflection to access the third party dll, because it
is not signed, and not in the GAC. The dlls are also not in a
subdirectory of our app.
Maybe we are approaching this the wrong way (?)
Stephen.
Stephen,
Did you try to create a function with generic parameters? i.e.
void GenericHandler( object sender, EventArgs e)
{...}
typeof(O).GetEv ent("E").AddHan dler(o, new EventHandler(Ge nericHandler));
Alexander
"Stephen Ahn" <noaddress> wrote in message
news:OW******** ******@tk2msftn gp13.phx.gbl... Suppose I have object O with an event E that are defined in an assembly M that I am referencing in my code via reflection. M also defines object A which is an argument to E.
At compile-time, how can I write a function that meets the signature for event E, when the compiler doesn't know about A ?
I can solve this problem using Delegate.Create Delegate etc if the type of E's arguments are known at compile time, but what about when there is an unknown type ?
TIA, Stephen
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: tony kulik |
last post by:
This code works fine in ie and opera but not at all in Mozilla.
Anybody got a clue as to how to get it right?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script language="JavaScript" type="text/javascript">
function show(that)
{
if (box.style.visibility=='hidden') { that.style.visibility =
'visible'};
}
|
by: Todd |
last post by:
Is it possible to pass an argument by reference through
an event in C++ managed code? For example, can I do the
following?
public __gc class MyClass : public Control
{
public:
__event void MyEvent(bool &Cancel);
|
by: VK |
last post by:
My original idea of two trains, however pictural it was, appeared to be
wrong. The truth seems to be even more chaotic.
IE implements its standard down-up model: any mouse event goes from the
deepest visible element to the top. By carefully studying fromElement
and toElement properties, one can handle events on any point of their
way up.
...
|
by: Marcelo Cabrera |
last post by:
Hi,
I have a user control that in turn creates a bunch of webcontrols
dynamically and handles the events these webcontrols raise. It used to work
fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is
that the webcontrols get created on the OnLoad event of the usercontrol and
the event handlers are assigned at the same...
|
by: mflll |
last post by:
I am looking into the different techniques of handling arrays of edit
boxes in
Java Script. The first program below works fine. However, are there
better ways of
doing this, where the person writing the JavaScript doesn't have to
pass the index
in the "onChange" event name.
I thought that one might be able to use "this.value" or...
| |
by: 6tc1 |
last post by:
Hi all, I'm inquiring about the mechanism that is used to implement
event handlers in .NET (not really relevant, but I'm using C#).
Anyway, I've noticed that I can pass an object in an event argument and
if the receiver (event handler) of that event changes any of the
properties in that object, then the original object I passed is
changed. ...
|
by: Jonathan Wood |
last post by:
I'm building a Web application but this question should be common to all C#
applications.
When I use a class, and I want to add event handlers or override base class
methods, how do I know the correct syntax for those methods?
In MFC, I can simply choose event handlers from a list and they are inserted
automatically with the correct...
|
by: VAXman- |
last post by:
I have code which is created from a content mamagement system. It places
some handlers on tags with in-line registration:
<tag... onmousedown="mousedownHandler(this);" ...>
I want to modified the handler and access the event. Here's an example of
such (very contrived example):
fucntion mousedownHandler(obj) {
|
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 = Windows Forms class
B = a singleton hosted within A. B is responsible for dynamically loading
classes X, Y, and Z.
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |