Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2003

Tip: Looking for answers? Try searching our database.

Catching events in VBScripts

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sumit - 27 Sep 2003 00:06 GMT
Hi,
I have created a C# dll. I want to catch all the events fired by the
dll in my VBScript.
Here is my implementation of C# dll
[Guid("F3719701-A2D2-40c6-BF7A-FD72B827E2B6")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface IMyEvts
    {
        [DispId(3)]void Ring();
        [DispId(4)]void Tring(string argData);
    }

    [Guid("4A58F995-8B43-47e5-9A37-154B38BF966A")]
    public interface IMyEvtsHndlr
    {
        [DispId(1)]void CallRing();
        [DispId(2)]void CallTring();
    }

    public delegate void RingEvtHandler();
    public delegate void TringEvtHandler(object argData);
   

    [Guid("7EE087D9-42A8-47a0-89CA-098FB433A8D0"),
    ClassInterface(ClassInterfaceType.None),
    ComSourceInterfaces(typeof(IMyEvts))]
    public class MyEvts:IMyEvtsHndlr
    {   
       public event RingEvtHandler Ring;
        public event TringEvtHandler Tring;
       
        public void CallRing()
        {
            Ring();
        }

        public void CallTring()
        {
            object str = "Hi there";
            Tring(str);
        }

    }
Could some one please help.
Thanks,
Sumit
Vadim Melnik - 28 Sep 2003 22:39 GMT
Hi,

What is exactly problem you have? I didn't try this code but at first look
it seems fine (except "Tring" delegate declaration differs from IMyEvts
one - it uses object for "argData" argument type instead of string one).

In case you don't know how to handle events on script side please see
"Scripting Events" MSDN article
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/s
cripting04092001.asp


..
Cheers,
Vadim.

> Hi,
> I have created a C# dll. I want to catch all the events fired by the
[quoted text clipped - 41 lines]
> Thanks,
> Sumit
Sumit - 29 Sep 2003 19:40 GMT
Hi Vadim,
I have the VBScript code working too. its just that I
cannot catch the event. I added a piece of code in the dll
public void CallRing(){
if(Tring != null)
 Tring("Sumit");
else
System.Windows.Forms.MessageBox.Show ("Cannot call the
event", "My Application", MessageBoxButtons.OKCancel,
MessageBoxIcon.Asterisk);

}
Then when I call the Call ring function from VBScript I
get the messagebox. Could you tell me what am i missing?.
I called the same dll in VB and it works.
-SUmit

                >-----Original Message-----
>Hi,
>
[quoted text clipped - 57 lines]
>
>.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.