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

Why event doesnt fire in .NET object from VBS?


Code
-------------------

using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

namespace DEMONS
{

[ComVisible(false)]
public delegate void TestEventHandler();

[InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
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/attachme...postid=1081328
+----------------------------------------------------------------

-
senglor
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Nov 18 '05 #1
1 1118
Senglory,
VBScript doesn't support the range of constructs that .Net code does.
You are trying to use VBScript code to respond to an event in your .Net
object. Your problems are not stemmed from bugs in your code. You are
trying to use VBScript for something it was not intended.

Best regards,
Jeffrey Palermo

"senglory" <se*************@mail.codecomments.com> wrote in message
news:se*************@mail.codecomments.com...


Code:
--------------------

using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

namespace DEMONS
{

[ComVisible(false)]
public delegate void TestEventHandler();

[InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
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?
+----------------------------------------------------------------+
| Attachment filename: eventsforcom.zip |
|Download attachment: http://www.codecomments.com/attachme...postid=1081328 | +----------------------------------------------------------------+
--
senglory
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 18 '05 #2

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

Similar topics

0
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
4
by: Hilla | last post by:
Hi, Im trying to send an event from my ActiveX Dll that was written with ATL and for some reason i dont see that the event is really sent... - although it does get to the FIRE function. I put...
3
by: James Dunkerley | last post by:
Hi, I am trying to create a class which downloads a web page in the background and then raises an event in the original thread in which it was created. This class is going to be the basis of a...
5
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only...
1
by: Maurice Walmsley | last post by:
hello and thanks I am as green as mold when it comes to asp.net, so please bear with me. I am trying to get an asp.net page with a webform to work using codebehind. My class/routines work...
2
by: Shiju Poyilil | last post by:
I have a link button "lButton" created dynamically at the item databound event of the data grid "datagrid1" in the footer.so i want to execute the item command event of the datagrid on clicking...
4
by: EvelynAnd Ethan | last post by:
Hi, ItemCommand event not firing from a dynamic user control ,WHERE A DATAGRID HAS BUTTON,when i click on the linkbutton first time the itemcommand event doesnt fire,second time event fires up ...
19
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void...
0
by: xamman | last post by:
hello folks, when i added this custom control to my webform along with a submit button and while debugging i found that the cached 'change' event never gets fired when i key in text in the textbox....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.