S
senglory
Code
-------------------
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 i
uncommented i receive
Microsoft VBScript runtime error: Object doesn't support this propert
or method: 'obj.OnBeforeStartTest'
Whats wrong to my code - VBS and .NET
+----------------------------------------------------------------
| Attachment filename: eventsforcom.zip
|Download attachment: http://www.codecomments.com/attachment.php?postid=1081328
+----------------------------------------------------------------
-
senglor
-------------------
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 i
uncommented i receive
Microsoft VBScript runtime error: Object doesn't support this propert
or method: 'obj.OnBeforeStartTest'
Whats wrong to my code - VBS and .NET
+----------------------------------------------------------------
| Attachment filename: eventsforcom.zip
|Download attachment: http://www.codecomments.com/attachment.php?postid=1081328
+----------------------------------------------------------------
-
senglor