C# Remoted Event Source, COM Event Sink

C# Remoted Event Source, COM Event Sink

Post by Tim » Thu, 22 Sep 2005 00:58:51


Hi All,

I'm having trouble figuring this out. I have a C# object, which is
exposed to COM, and fires events. I also have a COM object that can
create the C# object, call DispEventAdvise to be the sink for these
events. This all works fine. Now I want to change it so that instead of
the COM object CoCreating the C# object, I have a C# server which
remotes the object. The COM object uses Activator::GetObject() to get
the remoted object, and then I want to call DispEventAdvise() to set
the COM object as an event sink for the remoted object. I can't get it
to work. DispEventAdvise returns hr = 0x8013150B. I'm assuming that
this should be possible, and help would be greatly appreciated.

My C# object...

using System;
using System.Runtime.InteropServices;

namespace EventSource
{
public delegate void OnCompleteDelegate();

// Define event sink interface to be implemented by the COM sink
[GuidAttribute("7D6A6BB0-C136-4a22-9F84-ABC8603B3D6F") ]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IEventTestEvents
{
[DispId(0)] void OnComplete();
}

[GuidAttribute("88A158C1-896C-467a-B3CC-9F2068093AE2") ]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEventTest
{
void FireCompleteEvent();
}

// Connects the event sink interface to a class
[ComSourceInterfaces(typeof(IEventTestEvents))]
[ClassInterface(ClassInterfaceType.None)]
public class EventTest : MarshalByRefObject, IEventTest
{
// URL information for remoting this object
public const String RemotingProtocol = "tcp://";
public const String RemotingPort = "1234";
public const String RemotingURI = "EventTestUri";
public const String RemotingLocal = RemotingProtocol + "localhost" +
":" + RemotingPort + "/" + RemotingURI;
public const String RemotingRemote = RemotingProtocol + "{0}" + ":" +
RemotingPort + "/" + RemotingURI;

public event OnCompleteDelegate OnComplete;

public EventTest()
{
}

public void FireCompleteEvent()
{
OnComplete();
}
}
}


The code in my COM object where I try to call DispEventAdvise...

EventSource::EventTest* et =
static_cast<EventSource::EventTest*>(System::Activator::GetObject(__typeof(EventSource::EventTest),
EventSource::EventTest::RemotingLocal));
System::IntPtr iUnknown =
System::Runtime::InteropServices::Marshal::GetIUnknownForObject(et);
IUnknown* pUnk = (IUnknown*)(void*)iUnknown;
HRESULT hr = DispEventAdvise(pUnk, &DIID_IEventTestEvents);

Thanks for any help,

Tim.
 
 
 

1. ATL Event Sink using C# DLL Event Source

2. Categorizer event sink / routing event sink

I want to reroute all email from a particular group of internal users
through another (non-Exchange) server which will pre-process their
email before it's sent to its final recipient.

The best way I can see to do this (I've only just started learning
about the way Exchange works though) is:
- create a Categorizer event sink to look up the group membership of
the sender. - if they belong to the group I want to reroute emails from
then add some kind of attribute to the email.
- create a Routing event sink to reroute the email based on the
attribute set in the Categorizer event sink.

Is this the best way to do it? I can't find much info on creating
categorizer sinks (or routing sinks for that matter: what kind of info
do I have access to in a routing sink?)

-- Jordan

3. Read event sink wanted! Custom event sink needed?

4. Protocol Event Sink Issue Using Manged .NET event sink.

5. Event ID: 1003, Event Type: Error ,Event Source: System Error,Event Category: (102)

6. creting event handler client in vc++ for Source c# event

7. Event Log Error: Event Source:WinMgmt Event ID:10

8. Event ID: 12292 & Event ID: 11 - Event Source: VSS

9. Event ID: 12292 & Event ID: 11 - Event Source: VSS

10. Event Type: Error, Event Source: Print, Event ID: 23

11. Source Event Log Event ID Event Type serial System 45

12. Event ID 36 Source W3SVC / Event ID 10004 Source DCOM