Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2008, 08:50 PM
Registered User
 
Join Date: Sep 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Raising COM Events in C# Class Library

Hi,
I am trying to use an ActiveX Control in a C# class library project. The ActiveX is an open source project that I found from net. I want to use this in a web application, but I don't want to expose any code. So I am trying to create a class library. I am raising the events as follows..

Code:
private CtConectorXClass ctiConnecter = new CtConectorXClass(); 
 
        public CTIOperations() 
        { 
            ctiConnecter.OnACSOpenStreamConf += new ICtConectorXEvents_OnACSOpenStreamConfEventHandler(objCTI_OnACSOpenStreamConf); 
            ctiConnecter.OnACSCloseStreamConf += new ICtConectorXEvents_OnACSCloseStreamConfEventHandler(objCTI_OnACSCloseStreamConf); 
        } 
 
        private void objCTI_OnACSOpenStreamConf(int invokeId, string apiVersion, string libVersion, string tsrvVersion, string drvVersion) 
        { 
            //Code 
        } 
 
        private void objCTI_OnACSCloseStreamConf(int invokeId) 
        { 
            //Code 
        } 
 
        public bool OpenStream() 
        { 
                int retCode = ctiConnecter.OpenStream(/*arguments*/); 
 
                if (retCode < 0) 
                    return false; 
                else 
                    return true; 
        } 
 
        public bool CloseStream() 
        { 
                int retCode = ctiConnecter.CloseStream(); 
 
                if (retCode < 0) 
                    return false; 
                else 
                    return true; 
        }
When I call the class library methods, from a ASP.Net application, the events are not getting raised.

When I referenced the OCX to a windows application, the events are getting raised

And if I refer the OCX directly in a web application, the events are getting raised. In the DLL, it is giving a COM Exception. The methods returns success values but in the Constructor, when the new delegate is created, its throwing a COM Exception.

Code:
Exception from HRESULT: 0x80040202 
System.Runtime.InteropServices.COMException (0x80040202): Exception from HRESULT: 0x80040202 
   at System.Runtime.InteropServices.ComTypes.IConnectionPoint.Advise(Object pUnkSink, Int32& pdwCookie) 
   at CtConectorXControl.ICtConectorXEvents_EventProvider.add_OnACSOpenStreamConf(ICtConectorXEvents_OnACSOpenStreamConfEventHandler ) 
   at CtConectorXControl.CtConectorXClass.add_OnACSOpenStreamConf(ICtConectorXEvents_OnACSOpenStreamConfEventHandler )
Only in the DLL, I cannot raise the events. Can anybody tell whether I am doing any mistake or the OCX may have some problems. Any help is highly appreciated..

Thanks
Sree





Similar Threads
Thread Thread Starter Forum Replies Last Post
use of class library Theone84 C# 1 July 26th, 2008 02:19 AM
How to use a class library vs2005? badboy700 Visual Studio 2005 2 December 10th, 2007 09:38 PM
Using a class library Kiran Patil VS.NET 2002/2003 0 August 19th, 2006 05:52 AM
Regarding Class Library (.dll) from class file manish.sharma04 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 March 3rd, 2006 07:32 AM
Class Library ~Bean~ ASP.NET 1.x and 2.0 Application Design 3 October 17th, 2005 07:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.