Delegate Failure after Migration to .NET 2.0 - Vista

V

VictorG

Hello,

I am converting a C# .NET 1.1 based system to .NET 2.0. I am
encountering a socket exception with delegate events. The system uses
an NT service as a remoting host that provides services that desktop
applications consume.

Exception Message:
SocketException : No connection could be made because the target
machine actively refused it.

We are using the tcp remoting channel with the binary formatter. This
works in Vista with .NET 1.1, but not in 2.0 Vista, with UAC on or
off. No other code has been changed, I only migrated the project
files, and tried to run.

The events are fired from the remoting host (service) back to the
client (desktop) in another process.

Here is how I initialize the tcp channel in the client, (basically the
same as server):
******************************************************************
BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();


IDictionary props = new Hashtable();
props["port"] = 0;
props["name"] = "ESF Channel";
props["machineName"] = "localhost";

ChannelServices.RegisterChannel(new TcpChannel(props, clientProv,
serverProv));

**************************************************************

Are there any known issues with the tcp channel and delegates in .NET
2.0/Vista?
Could this be a CAS security related problem?

Any help will be greatly appreciated.

Thanks,
Victor Grippi
 
B

Bram

Hey Victor,

Remoting became a lot harder to get right in .NET 2.0 and
unfortunately there is not that many good documentation, since most
snippets out there don't actually work in .NET 2.0. So frankly, I
think for once it's NET 2.0 and not Vista which is the culprit. After
a *lot* of trial and error, I came up with the following code which
happily allows for raising exceptions, etc...:

Server setup

IDictionary props = new Hashtable();
props["port"] = 19681;
BinaryServerFormatterSinkProvider ssp = new
BinaryServerFormatterSinkProvider();
ssp.TypeFilterLevel = TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider csp = new
BinaryClientFormatterSinkProvider();
TcpChannel myChannel = new TcpChannel(props, csp, ssp);
ChannelServices.RegisterChannel(myChannel, false);
ActivatedServiceTypeEntry entry = new
ActivatedServiceTypeEntry(typeof(PokerClient));
RemotingConfiguration.ApplicationName = "Poker";
RemotingConfiguration.RegisterActivatedServiceType(entry);


Client setup

IDictionary props = new Hashtable();
props["port"] = 0;
BinaryServerFormatterSinkProvider ssp = new
BinaryServerFormatterSinkProvider();
ssp.TypeFilterLevel = TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider csp = new
BinaryClientFormatterSinkProvider();
TcpChannel myChannel = new TcpChannel(props, csp, ssp);
ChannelServices.RegisterChannel(myChannel, false);
string url = "tcp://" + hostname + ":19681/Poker";
ActivatedClientTypeEntry entry = new
ActivatedClientTypeEntry(typeof(PokerClient), url);
RemotingConfiguration.ApplicationName = "Poker";
RemotingConfiguration.RegisterActivatedClientType(entry);
object[] urlParm = { new UrlAttribute(url) };
PokerClient client = new PokerClient();

I hope this helps!

Regards,
Bram



Hello,

I am converting a C# .NET 1.1 based system to .NET 2.0. I am
encountering a socket exception with delegate events. The system uses
an NT service as a remoting host that provides services that desktop
applications consume.

Exception Message:
SocketException : No connection could be made because the target
machine actively refused it.

We are using the tcp remoting channel with the binary formatter. This
works in Vista with .NET 1.1, but not in 2.0 Vista, with UAC on or
off. No other code has been changed, I only migrated the project
files, and tried to run.

The events are fired from the remoting host (service) back to the
client (desktop) in another process.

Here is how I initialize the tcp channel in the client, (basically the
same as server):
******************************************************************
BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();

IDictionary props = new Hashtable();
props["port"] = 0;
props["name"] = "ESF Channel";
props["machineName"] = "localhost";

ChannelServices.RegisterChannel(new TcpChannel(props, clientProv,
serverProv));

**************************************************************

Are there any known issues with the tcp channel and delegates in .NET
2.0/Vista?
Could this be a CAS security related problem?

Any help will be greatly appreciated.

Thanks,
Victor Grippi
 
V

VictorG

Hi Bram,

Thanks for your response.

Are you saying that you had to make the below calls - in order for
remoting to work in .NET 2.0 for you?

ActivatedClientTypeEntry entry = new
ActivatedClientTypeEntry(typeof(PokerClient), url);
RemotingConfiguration.ApplicationName = "Poker";
RemotingConfiguration.RegisterActivatedClientType(entry);


I make the single below call in order to register my server type. All
my objects are server activated, and their proxy is obtained using the
Proxy Factory Pattern. But the event delegates are passed from the
client to a notification service, a hosted service in my server, and
stored in a list. When anyone publishes an event, the notification
service fires the appropriate delegate it has previous obtained from
the client.

RemotingConfiguration.RegisterWellKnownServiceType(
typeof(IService), objectUri, WellKnownObjectMode.Singleton);


I set the TypeFilterLevel to Full to allow the server to call back to
the client through the tcp channel.

It is this call that has the problem with the tcp remoting channel and
throws the socket exception, only in .NET 2.0.


Victor Grippi




Hey Victor,

Remoting became a lot harder to get right in .NET 2.0 and
unfortunately there is not that many good documentation, since most
snippets out there don't actually work in .NET 2.0. So frankly, I
think for once it's NET 2.0 and not Vista which is the culprit. After
a *lot* of trial and error, I came up with the following code which
happily allows for raising exceptions, etc...:

Server setup

IDictionary props = new Hashtable();
props["port"] = 19681;
BinaryServerFormatterSinkProvider ssp = new
BinaryServerFormatterSinkProvider();
ssp.TypeFilterLevel = TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider csp = new
BinaryClientFormatterSinkProvider();
TcpChannel myChannel = new TcpChannel(props, csp, ssp);
ChannelServices.RegisterChannel(myChannel, false);
ActivatedServiceTypeEntry entry = new
ActivatedServiceTypeEntry(typeof(PokerClient));
RemotingConfiguration.ApplicationName = "Poker";
RemotingConfiguration.RegisterActivatedServiceType(entry);

Client setup

IDictionary props = new Hashtable();
props["port"] = 0;
BinaryServerFormatterSinkProvider ssp = new
BinaryServerFormatterSinkProvider();
ssp.TypeFilterLevel = TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider csp = new
BinaryClientFormatterSinkProvider();
TcpChannel myChannel = new TcpChannel(props, csp, ssp);
ChannelServices.RegisterChannel(myChannel, false);
string url = "tcp://" + hostname + ":19681/Poker";
ActivatedClientTypeEntry entry = new
ActivatedClientTypeEntry(typeof(PokerClient), url);
RemotingConfiguration.ApplicationName = "Poker";
RemotingConfiguration.RegisterActivatedClientType(entry);
object[] urlParm = { new UrlAttribute(url) };
PokerClient client = new PokerClient();

I hope this helps!

Regards,
Bram

I am converting a C# .NET 1.1 based system to .NET 2.0. I am
encountering a socket exception with delegate events. The system uses
an NT service as a remoting host that provides services that desktop
applications consume.
Exception Message:
SocketException : No connection could be made because the target
machine actively refused it.
We are using the tcp remoting channel with the binary formatter. This
works in Vista with .NET 1.1, but not in 2.0 Vista, with UAC on or
off. No other code has been changed, I only migrated the project
files, and tried to run.
The events are fired from the remoting host (service) back to the
client (desktop) in another process.
Here is how I initialize the tcp channel in the client, (basically the
same as server):
******************************************************************
BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = 0;
props["name"] = "ESF Channel";
props["machineName"] = "localhost";
ChannelServices.RegisterChannel(new TcpChannel(props, clientProv,
serverProv));

Are there any known issues with the tcp channel and delegates in .NET
2.0/Vista?
Could this be a CAS security related problem?
Any help will be greatly appreciated.
Thanks,
Victor Grippi- Hide quoted text -

- Show quoted text -
 
B

Bram

Hi Victor,

Basically, there are two methods of remote activation: Client side
activation and server side activation. In my experience, client-side
activation is most suited for a client-server type scenario where
there is a persistent connection between client and server (for
instance: a chat client). I am not sure which scenario would be the
best choice in your case.

Regards
Bram
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top