473,408 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Reflection : GetEvent, GetMethod, Bind Method on Event

TValue oItem = (TValue)Activator.CreateInstance(typeof(TValue),
BindingFlags.Instance | BindingFlags.NonPublic,
null,
new object[] { m_nCleTemporaire },
System.Globalization.CultureInfo.CurrentCulture);

EventInfo oPropertyChanged = oItem.GetType().GetEvent("PropertyChanged");
MethodInfo eventHandler = this.GetType().GetMethod("Item_PropertyChanged",
BindingFlags.Instance | BindingFlags.NonPublic);

/** Next code line fails **/
Delegate d = Delegate.CreateDelegate(oPropertyChanged.EventHand lerType,
eventHandler);

The system says that it cannot murge the delegate with the defined type.

Why ???
Claude
Apr 4 '08 #1
1 2487
On Apr 4, 1:35*pm, Claude <Cla...@discussions.microsoft.comwrote:
TValue oItem = (TValue)Activator.CreateInstance(typeof(TValue),
* * * * * * * * * * * * *BindingFlags.Instance |BindingFlags.NonPublic,
* * * * * * * * * * * * *null,
* * * * new object[] { m_nCleTemporaire }, * * * * * ** * * * * * * * * * *
* * * * * * * * * * * * System.Globalization.CultureInfo.CurrentCulture);

EventInfo oPropertyChanged = oItem.GetType().GetEvent("PropertyChanged");
MethodInfo eventHandler = this.GetType().GetMethod("Item_PropertyChanged", *
BindingFlags.Instance | BindingFlags.NonPublic);

/** Next code line fails **/
Delegate d = Delegate.CreateDelegate(oPropertyChanged.EventHand lerType,
eventHandler);

The system says that it cannot murge the delegate with the defined type.

Why ???
*Claude
Are you sure that PropertyChanged event is of type EventHandlerType?
Most usually you get this error because of that
Apr 4 '08 #2

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

Similar topics

9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
0
by: Nigel Sampson | last post by:
ey all, I'm in the process of creating a method of tracking whenever an objects properties are changed. Since its not possible to alter existing types I decided to used a proxy generated using...
4
by: Tim Werth | last post by:
I am trying to use reflection to add an event handler for the RowUpdated event of the OracleDataAdapter object (ODP.NET), but the same thing can be said for SqlDataAdapter if you only use...
6
by: Joanna Carter \(TeamB\) | last post by:
Hi folks I have a Generic Value Type and I want to detect when the internal value changes. /////////////////////////////// public delegate void ValueTypeValidationHandler<T>(T oldValue, T...
0
by: Shawn Hogan | last post by:
Hi everyone, I've been trying to execute a control's private event code via reflection from another class with the goal of potentially doing some unit testing. The examples below are trying to...
2
by: Luis Arvayo | last post by:
Hi, In c#, I need to dynamically create types at runtime that will consist of the following: - inherits from a given interface - will have a constructor with an int argument
0
by: Coder Guy | last post by:
I am trying to subscribe to an event using reflection. The guarantee is that the the event delegate will be of type EventHandler or at least the e parameter inherits from EventArgs. Hard coding...
10
by: Ron | last post by:
I have a situation where I have an object name as a string, and a method as a string. I need to construct a click handler with those two bits of information. This is what I came up with so far......
5
by: Klaudiusz Bryja | last post by:
Hi, This is for NetCF 2.0. I need to create event handling code which using reflection. I have some parameters in XML which describe how event should be handled. I have code to create...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
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...

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.