Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is there any reason to implement a collection now that we have generics? Pin
PIEBALDconsult22-Dec-07 17:02
mvePIEBALDconsult22-Dec-07 17:02 
AnswerRe: Is there any reason to implement a collection now that we have generics? Pin
darkelv22-Dec-07 17:15
darkelv22-Dec-07 17:15 
GeneralRe: Is there any reason to implement a collection now that we have generics? Pin
JoeRip22-Dec-07 19:56
JoeRip22-Dec-07 19:56 
GeneralRe: Is there any reason to implement a collection now that we have generics? Pin
JoeRip22-Dec-07 20:01
JoeRip22-Dec-07 20:01 
GeneralRe: Is there any reason to implement a collection now that we have generics? Pin
JoeRip22-Dec-07 20:05
JoeRip22-Dec-07 20:05 
GeneralRe: Is there any reason to implement a collection now that we have generics? Pin
PIEBALDconsult23-Dec-07 3:22
mvePIEBALDconsult23-Dec-07 3:22 
AnswerRe: Is there any reason to implement a collection now that we have generics? Pin
Scott Dorman23-Dec-07 1:43
professionalScott Dorman23-Dec-07 1:43 
QuestionC# Managed Event Not Fired In VB6 Event Sink [modified] Pin
wentz22-Dec-07 8:16
wentz22-Dec-07 8:16 
I have a C# class, say PhoneControlX, which is compiled into one DLL and referenced by both managed .NET and Unmanaged COM client (C# Window form and VB6 respectively). Via COM Interop, PhoneControlX implements IPhoneControlX and IPhoneControlXEvents to expose a couple of methods and one event, CauseCallOffered, to VB6 event sink. The C# Window form invokes methods and receive the event without any problem, while the VB6 works fine on method invocation only but fails on event sinking.

Specifically, PhoneControlX registers itself to PhoneControlServer, a remote object gotten via Activator. When a call comes in, PhoneControlServer will invoke CauseCallback to fire the event, PhoneControlCallback and hence PhoneControlCallbackEventHandler. However, when the client is VB6, PhoneControlCallbackEventHandler is never invoked.

Part of the code is as follows:
===============================
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces( typeof(IPhoneControlXEvents) )]
public class PhoneControlX : MarshalByRefObject, IPhoneControlX
{
  public event PhoneControlXEventHandler OnCallOffered;
  ...
  public bool Connect()
  {
    BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();   
    BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();   
    serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
    IDictionary props = new Hashtable();     
    props["name"] = "RemotingClient";   
    props["port"] = 0;   
    _HttpChannel = new HttpChannel(props, clientProvider, serverProvider);   
    ChannelServices.RegisterChannel(_HttpChannel);

    _PhoneControlServer = (IPhoneControlServer) Activator.GetObject(typeof IPhoneControlServer),remotingURI);
    
    _PhoneControlServer.RegisterCallback(this);
  }

  public void PhoneControlCallbackEventHandler(object sender, IPhoneControlEventArgs e)
  {
    //this event handler is never invoked when PhoneControlX is instantiated by VB6 client.
    PhoneControlXEventHandler xe = new PhoneControlXEventHandler(CauseCallOffered);
    AsyncCallback acbCauseCallOfferedComplete = new AsyncCallback(CauseCallOfferedComplete);
    xe.BeginInvoke(e,acbCauseCallOfferedComplete,PhoneControlOperation.CallOffered);
  }
}

public class PhoneControlServer : MarshalByRefObject, IPhoneControlServer
{
  public event PhoneControlEventHandler PhoneControlCallback;
  ...
  public void RegisterCallback(IPhoneControlX x)
  {
    this.PhoneControlCallback += new PhoneControlEventHandler(x.PhoneControlCallbackEventHandler);
  }
  ...
  public void CauseCallback(IPhoneControlEventArgs e)
  {
    if(this.PhoneControlCallback != null)
      PhoneControlCallback(this,e);
  }
}

I've worked on this problem for almost one week.
Any hints, directions or help is highly appreciated.
modified on Saturday, December 22, 2007 3:13:18 PM

Generalquestions about properties Pin
Xmen Real 22-Dec-07 3:56
professional Xmen Real 22-Dec-07 3:56 
GeneralRe: questions about properties Pin
Christian Graus22-Dec-07 9:18
protectorChristian Graus22-Dec-07 9:18 
GeneralRe: questions about properties Pin
PIEBALDconsult22-Dec-07 17:04
mvePIEBALDconsult22-Dec-07 17:04 
GeneralRe: questions about properties Pin
darkelv22-Dec-07 17:05
darkelv22-Dec-07 17:05 
GeneralRe: questions about properties [modified] Pin
Xmen Real 22-Dec-07 17:13
professional Xmen Real 22-Dec-07 17:13 
GeneralRe: questions about properties Pin
darkelv22-Dec-07 18:26
darkelv22-Dec-07 18:26 
GeneralRe: questions about properties Pin
Xmen Real 23-Dec-07 14:55
professional Xmen Real 23-Dec-07 14:55 
GeneralNumberFormatInfo Problem. Pin
hdv21222-Dec-07 3:34
hdv21222-Dec-07 3:34 
GeneralRe: NumberFormatInfo Problem. Pin
Paul Conrad22-Dec-07 7:01
professionalPaul Conrad22-Dec-07 7:01 
GeneralRe: NumberFormatInfo Problem. Pin
hdv21222-Dec-07 10:36
hdv21222-Dec-07 10:36 
GeneralCrystal Report Pin
Shaahinm22-Dec-07 0:19
Shaahinm22-Dec-07 0:19 
GeneralRe: Crystal Report Pin
Paul Conrad22-Dec-07 7:02
professionalPaul Conrad22-Dec-07 7:02 
Questionhow to use this code ? Pin
az_farzaneh21-Dec-07 23:01
az_farzaneh21-Dec-07 23:01 
AnswerRe: how to use this code ? Pin
Xmen Real 22-Dec-07 3:58
professional Xmen Real 22-Dec-07 3:58 
AnswerRe: how to use this code ? Pin
Paul Conrad22-Dec-07 7:03
professionalPaul Conrad22-Dec-07 7:03 
GeneralMultiview in Winform app. Pin
arefkarimi21-Dec-07 22:41
arefkarimi21-Dec-07 22:41 
QuestionC# and Serial Ports Pin
Matti_P21-Dec-07 22:27
Matti_P21-Dec-07 22:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.