Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2003, 08:46 PM
roy roy is offline
Registered User
 
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Define events in COM built in .NET

Hi everyone.
I built in .NET a 'class library' project , which then I
compiled with "Register for COM interop".
I also added some events.

I use this component in VB6, but I can't hook up to the
events.
Can someone please help?

In the .NET component's code, I tried to define events in
      2 different ways:
1."
  public delegate void ClickedEventHandler(string val);
  public event ClickedEventHandler Clicked;
  and then...
  if(Clicked!=null) Clicked(txt.value);
  "

2. [InterfaceTypeAttribute
(ComInterfaceType.InterfaceIsDual)]
    public interface IMonitorEvent
      {
         void HandleMonitorEvent(bool IsEmergency);
      }


Then, in order to hook up to those events in VB6:
1. I added a refernce in VB6 to the component.
2. I created instance
   "
    Dim MyObj As ContainerForIE.Form1
    Set MyObj = CreateObject("ContainerForIE.Form1")
    MyObj.Show
   "
3. I tried to use
   "Public WithEvents MyObj As ContainerForIE.Form1"
   But it raises an error "Object does not source
   automation events"

Can anyone help please?


 
Old October 22nd, 2003, 11:07 PM
roy roy is offline
Registered User
 
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You need to basically declare an interface, provide a GUID to that
interface, make it IDispatch based and use ComSourceInterfaces() to
assign that interface as the event interface. Then use delegates to
point to the methods exposed by the interface.

If you did not understand what I am talking about, check out MSDN for
"Raising Events handled by COM Sink" topic. In VS.NET 2003 its in,
ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconraisingeventshandledbycomsink.htm
HTH.








Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire events of a Active X dll in ASP.NET Brijendra Pandey ASP.NET 3.5 Professionals 1 October 4th, 2008 05:44 PM
reg: built in classes in dot net framework m_kali2000 General .NET 1 October 10th, 2004 11:13 AM
events module in Building an asp.net intranet nickm All Other Wrox Books 1 August 25th, 2004 01:07 PM
VS.net Question : Protected with Events shahchi1 VS.NET 2002/2003 2 May 23rd, 2004 08:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.