IpcChannel and Remoting Events
Just solved a problem that I had a hard time googling to solve, so I wanted the next guy to have an easier time :
When creating a remoting connection from a client to a server, and you want the server to be able to raise events back to the client,
you must set a property called "tokenImpersonationLevel" to "impersonation" on the dictionary used to initialize the channel.
i.e. :
/// <summary>
/// Setup a client channel for the server to use during callbacks (events)
/// </summary>
private void SetupRemotingChannel()
{
BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["name"] = props["portName"] = _clientChannelName = _clientChannelBaseName + Guid.NewGuid().ToString();
props["tokenImpersonationLevel"] = "impersonation";
serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
IpcChannel chan = new IpcChannel(props, clientProv, serverProv);
ChannelServices.RegisterChannel(chan, true);
}