473,327 Members | 2,012 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,327 software developers and data experts.

How to handle a superclass' event Help.

Hello,
I have a VB.NET class that raises a MapSet event that passes an argument of
type interop.MapObjects2.MapClass.

I have a C# class that inherits from this VB.NET class. How can I handle the
VB.NET event in the C# class?
In VB.NET, you would just write:
Handles MyBase.MapSet

I would appreciate any help on this.
Steve
Nov 15 '05 #1
3 4434
Simple, just like this in the inherited class:

base.MapSet += new EventHandler(this.MapSetFunction)

Where "EventHandler" is the delegate that is specified for the MapSet event
and "MapSetFunction") is the method you wish the event to raise. The
"base." is not required if you are not overriding the event with a new
event.

-Noah Coad
Microsoft MVP & MCP [.NET/C#]
"Steve Long" <No***************@co.clark.wa.us> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hello,
I have a VB.NET class that raises a MapSet event that passes an argument of type interop.MapObjects2.MapClass.

I have a C# class that inherits from this VB.NET class. How can I handle the VB.NET event in the C# class?
In VB.NET, you would just write:
Handles MyBase.MapSet

I would appreciate any help on this.
Steve

Nov 15 '05 #2
Cool. Let me try that. I tried overriding but the compiler complained with
the following error:

COM Interop registration failed. Type library exporter encountered an error
while processing 'WeedPlugin1.CWeedPlugin.add_MapSet(value), WeedPlugin1'.
Error: Type library exporter can not load type MapSetEventHandler (error:
System.TypeLoadException: Could not load type MapSetEventHandler from
assembly DotNetPlugin, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=968e71ee5ce24c2c.).

As you can see, the event handler is MapSetEventHandler.
I'll see if it works the other way and let you know. Thanks for your help
btw.

Steve

"Noah Coad [MVP .NET/C#]" <no**@coad.net> wrote in message
news:OS*************@tk2msftngp13.phx.gbl...
Simple, just like this in the inherited class:

base.MapSet += new EventHandler(this.MapSetFunction)

Where "EventHandler" is the delegate that is specified for the MapSet event and "MapSetFunction") is the method you wish the event to raise. The
"base." is not required if you are not overriding the event with a new
event.

-Noah Coad
Microsoft MVP & MCP [.NET/C#]
"Steve Long" <No***************@co.clark.wa.us> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hello,
I have a VB.NET class that raises a MapSet event that passes an argument

of
type interop.MapObjects2.MapClass.

I have a C# class that inherits from this VB.NET class. How can I handle

the
VB.NET event in the C# class?
In VB.NET, you would just write:
Handles MyBase.MapSet

I would appreciate any help on this.
Steve


Nov 15 '05 #3
Okay, so I'm getting the error below whether I override the VB.NET event or
if I just add the event handling in the inherited class. If I just simply
add the event handling in the inherited class (as Noah suggested), I get the
error in VB6 when I instantiate the obejct. If I override the event, I get
the same error when I compile (the compiler throws the error).

In VB.NET, I had orginally just declared the event and let the compiler
implicitly declare the event handler. Then I changed it to declaring the
event handler and then the event using the following syntax:

Public Delegate Sub MapSetEventHandler(ByRef map As interop.MapObjects2.Map)

Public Event MapSet As MapSetEventHandler

I get the same error either way. Anybody know why I might be getting this
error? I have deleted the assemblies and .pdb files and recompiled several
times to no avail.

Steve

"Steve Long" <No***************@co.clark.wa.us> wrote in message
news:#Y**************@TK2MSFTNGP12.phx.gbl...
Cool. Let me try that. I tried overriding but the compiler complained with
the following error:

COM Interop registration failed. Type library exporter encountered an error while processing 'WeedPlugin1.CWeedPlugin.add_MapSet(value), WeedPlugin1'.
Error: Type library exporter can not load type MapSetEventHandler (error:
System.TypeLoadException: Could not load type MapSetEventHandler from
assembly DotNetPlugin, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=968e71ee5ce24c2c.).

As you can see, the event handler is MapSetEventHandler.
I'll see if it works the other way and let you know. Thanks for your help
btw.

Steve

"Noah Coad [MVP .NET/C#]" <no**@coad.net> wrote in message
news:OS*************@tk2msftngp13.phx.gbl...
Simple, just like this in the inherited class:

base.MapSet += new EventHandler(this.MapSetFunction)

Where "EventHandler" is the delegate that is specified for the MapSet

event
and "MapSetFunction") is the method you wish the event to raise. The
"base." is not required if you are not overriding the event with a new
event.

-Noah Coad
Microsoft MVP & MCP [.NET/C#]
"Steve Long" <No***************@co.clark.wa.us> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hello,
I have a VB.NET class that raises a MapSet event that passes an
argument of
type interop.MapObjects2.MapClass.

I have a C# class that inherits from this VB.NET class. How can I
handle the
VB.NET event in the C# class?
In VB.NET, you would just write:
Handles MyBase.MapSet

I would appreciate any help on this.
Steve



Nov 15 '05 #4

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

Similar topics

2
by: stephane | last post by:
Hi all, What I am trying to achieve is an 'inherits' method similar to Douglas Crockford's (http://www.crockford.com/javascript/inheritance.html) but that can enable access to the superclass'...
2
by: rawCoder | last post by:
Hi I am having this InvalidOperationException with message Cannot call Invoke or InvokeAsync on a control until the window handle has been created This is raised when i try to invoke a method...
7
by: lkr | last post by:
hi is there is anyway to capture the document events of a MSWord?eg:I have to handle the event awhen WM_KEYUP or anyother events will occur. give me a solution............ thanks in advance lkr
6
by: Leandro Berti via DotNetMonster.com | last post by:
Hi All, I wrote a code to do serial communication with an equipament. When i use the code outside of threaded class it seens work properly, but when i put inside a class and execute a thread in...
5
by: Jon B | last post by:
Hi There! How to handle the events of a dynamically added user control? e.g. I have following code... Dim myUserControl as Object = LoadControl("myFirstControl.ascx") myFirstControl fires...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
13
by: Abhishek | last post by:
Hi, how do I pass the handle of a control to the win32 api mouse_event. so that it will create the click event on that application only even if there is any other window in front of it. I dont...
2
by: Mark Brading | last post by:
Hi all, I am trying to declare a Map object with an abstract superclass (TableFields_v2) object as follows:- private Map<Integer, TableFields_v2> elementList; When I come to create the object...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.