none
Consuming .NET events in VBScript RRS feed

  • Question

  • Hi!
    I'm trying to have VBScript process an event generated from a .NET component.
    For a start I copied the .NET component straight out of http://msdn.microsoft.com/en-us/library/dd8bf0x3.aspx .
    The changes I made were
    • I added a normal method called "getValue()" that returns  string
    • I removed the Pulse event.
    Apart from that I made the assembly COM visible and registered it for COM interop (checked the appropriate checkboxes in visual studio).
    This is the code:
    using System.Runtime.InteropServices;
    
    namespace PureEvents
    	{
    	public delegate void ClickDelegate(int x, int y);
    	public delegate void ResizeDelegate();
    
    	// Step 1: Defines an event sink interface (ButtonEvents) to be     
    	// implemented by the COM sink.
    	[GuidAttribute("1A585C4D-3371-48dc-AF8A-AFFECC1B0967")]
    	[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
    	public interface ButtonEvents
    		{
    		void Click(int x, int y);
    		void Resize();
    		}
    	// Step 2: Connects the event sink interface to a class 
    	// by passing the namespace and event sink interface
    // ("EventSource.ButtonEvents, EventSrc").
    [ComSourceInterfaces(typeof(ButtonEvents))] public class PureEvents { public event ClickDelegate Click; public event ResizeDelegate Resize; public string getValue() { return "Normal method call"; } public PureEvents() { } public void CauseClickEvent(int x, int y) { Click(x, y); } public void CauseResizeEvent() { Resize(); } } }
    The VBscript looks like this:
    sub X_Resize
    msgBox "Here"
    end sub
    
    set BFI=wscript.createobject("PureEvents.PureEvents","X_")
    msgBox BFI.GetValue()
    
    BFI.CauseResizeEvent
    msgBox "There"
    
    
    
    
    The .vbs file doesn't run in any IIS or Internet Explorer, it just runs by double clicking on it.
    What happens is that GetValue works normally but CauseResizeEvent fails with 80004001 "Method or process not implemented".
    If I comment out the Resize() call in C#, the method runs normally.
    I suspect that the X_Resize doesn't get connected to the BFI object.

    Does anyone know how this is supposed to work?

    I'd love to have any assistance in this.
    Lots of Greetings!
    Volker

    Volker
    Wednesday, June 3, 2009 6:37 PM

Answers

  • Found the problem.
    The Example works ONLY in VBScript, if the ButtonEvents-Enterface has DispIds.
    Volker
    • Marked as answer by Hetzi Thursday, June 4, 2009 12:39 PM
    Thursday, June 4, 2009 12:36 PM