473,795 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why event doesnt fire in .NET object from VBS?


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

using System;
using System.Runtime. InteropServices ;
using System.Runtime. CompilerService s;

namespace DEMONS
{

[ComVisible(fals e)]
public delegate void TestEventHandle r();

[InterfaceType(C omInterfaceType .InterfaceIsIDi spatch)]
public interface ControlEvents
{
//[DispIdAttribute (0x60020000)]
void OnBeforeStartTe st();
}

[
ClassInterface( ClassInterfaceT ype.AutoDispatc h),
ComSourceInterf aces(typeof(Con trolEvents))
]
public class Demo
{
public event TestEventHandle r OnBeforeStartTe st;
public void TEST()
{
Console.WriteLi ne("TEST()");

if (OnBeforeStartT est != null)
OnBeforeStartTe st();
}
}
}

-------------------

VBS:

sub OnTest2()
msgbox "VBSCRIPT OnTest"
end sub

sub obj_OnBeforeSta rtMigration()
msgbox "VBSCRIPT OnTest"
end sub

set obj = createobject("D EMONS.Demo")
set obj.OnBeforeSta rtTest = 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.OnBeforeSt artTest'

Whats wrong to my code - VBS and .NET

+----------------------------------------------------------------
| Attachment filename: eventsforcom.zi p
|Download attachment: http://www.codecomments.com/attachme...postid=1081328
+----------------------------------------------------------------

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

Nov 18 '05 #1
1 1131
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.codecomm ents.com> wrote in message
news:se******** *****@mail.code comments.com...


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

using System;
using System.Runtime. InteropServices ;
using System.Runtime. CompilerService s;

namespace DEMONS
{

[ComVisible(fals e)]
public delegate void TestEventHandle r();

[InterfaceType(C omInterfaceType .InterfaceIsIDi spatch)]
public interface ControlEvents
{
//[DispIdAttribute (0x60020000)]
void OnBeforeStartTe st();
}

[
ClassInterface( ClassInterfaceT ype.AutoDispatc h),
ComSourceInterf aces(typeof(Con trolEvents))
]
public class Demo
{
public event TestEventHandle r OnBeforeStartTe st;
public void TEST()
{
Console.WriteLi ne("TEST()");

if (OnBeforeStartT est != null)
OnBeforeStartTe st();
}
}
}

--------------------

VBS:

sub OnTest2()
msgbox "VBSCRIPT OnTest"
end sub

sub obj_OnBeforeSta rtMigration()
msgbox "VBSCRIPT OnTest"
end sub

set obj = createobject("D EMONS.Demo")
set obj.OnBeforeSta rtTest = 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.OnBeforeSt artTest'

Whats wrong to my code - VBS and .NET?
+----------------------------------------------------------------+
| Attachment filename: eventsforcom.zi p |
|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
7048
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
9924
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
1705
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 breakpoints and i see that although its supposed to get to - template <class T, const IID* piid, class CDV> STDMETHODIMP IConnectionPointImpl<T, piid, CDV>::Advise(IUnknown* pUnkSink, DWORD* pdwCookie) In ATLCOM.h
3
1955
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 set of different applications and I want to hide the threading from the other layers. Any suggestions as to how to do this? Thanks James
5
6830
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 way is using javascript - does anybody have a sample for this ? Thanks
1
1532
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 fine, just doing simple stuff like changing the text of lables. I cant seem to get this to work though;
2
1541
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 the dynamicaly created link button, but when at runtime i click the dymanic created control it disapears from the datagrid footer and then it doesnt fire the itemcommand event of the datagrid. I am pasting below the pieces of my code for your...
4
4162
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 any answers?? Regards,
19
4759
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 DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
0
881
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. it will only fire if you add a 'text' attribute in the html. if the change event doesnt fire the viewstate wont be kept for this textbox. any idea what i am doing wrong ?....thanks x Imports System.ComponentModel
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10448
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9046
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6784
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.