Gatwick
November 26th, 2004, 11:09 AM
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace DEMONS
{
[ComVisible(false)]
public delegate void TestEventHandler();
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ControlEvents
{
//[DispIdAttribute(0x60020000)]
void OnBeforeStartTest();
}
[
ClassInterface(ClassInterfaceType.AutoDispatch),
ComSourceInterfaces(typeof(ControlEvents))
]
public class Demo
{
public event TestEventHandler OnBeforeStartTest;
public void TEST()
{
Console.WriteLine("TEST()");
if (OnBeforeStartTest != null)
OnBeforeStartTest();
}
}
}
VBS:
sub OnTest2()
msgbox "VBSCRIPT OnTest"
end sub
sub obj_OnBeforeStartMigration()
msgbox "VBSCRIPT OnTest"
end sub
set obj = createobject("DEMONS.Demo")
set obj.OnBeforeStartTest = GetRef("OnTest2")
obj.TEST
--------------------------------
obj.TEST works fine (if to comment upper string). But when I leave it uncommented i receive
Microsoft VBScript runtime error: Object doesn't support this property or method: 'obj.OnBeforeStartTest'
Whats wrong to my code - VBS and .NET?
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace DEMONS
{
[ComVisible(false)]
public delegate void TestEventHandler();
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ControlEvents
{
//[DispIdAttribute(0x60020000)]
void OnBeforeStartTest();
}
[
ClassInterface(ClassInterfaceType.AutoDispatch),
ComSourceInterfaces(typeof(ControlEvents))
]
public class Demo
{
public event TestEventHandler OnBeforeStartTest;
public void TEST()
{
Console.WriteLine("TEST()");
if (OnBeforeStartTest != null)
OnBeforeStartTest();
}
}
}
VBS:
sub OnTest2()
msgbox "VBSCRIPT OnTest"
end sub
sub obj_OnBeforeStartMigration()
msgbox "VBSCRIPT OnTest"
end sub
set obj = createobject("DEMONS.Demo")
set obj.OnBeforeStartTest = GetRef("OnTest2")
obj.TEST
--------------------------------
obj.TEST works fine (if to comment upper string). But when I leave it uncommented i receive
Microsoft VBScript runtime error: Object doesn't support this property or method: 'obj.OnBeforeStartTest'
Whats wrong to my code - VBS and .NET?