Cjkr

I have a very basic remoting app, as soon as I try to call a method on a remote object, I get the following error:

"An attempt was made to access a socket in a way forbidden by its access permissions"

This same code works perfectly fine on Windows XP Professional. I am running the VisualStudio instance with Vista Admin privelages, and I've even created exceptions for it in the firewall, and its still not working.

Can anyone advise on this I have had a lot of trouble with remoting and I'm about to give up and just use raw sockets.



Re: .NET Remoting and Runtime Serialization Getting strange error when running a simple remoting app on Vista

Cjkr

I just tried allowing all outbound connections in the Vista firewall and the error message has changed to the following:

"No connection could be made because the target machine actively refused it"

Which suggests I would need to allow all inbound.

THe thing is I explicitely gave the two apps (client and server) permission to accept connections but it seems they are being ignored.





Re: .NET Remoting and Runtime Serialization Getting strange error when running a simple remoting app on Vista

John Justice - MSFT

Hi Cjkr, can you try narrowing down your code to a (very basic) ~20 line repro and see if you still get the error If you do, go ahead and post the repro code inline and I'll try it over here.

Cheers,

JJustice [MSFT]





Re: .NET Remoting and Runtime Serialization Getting strange error when running a simple remoting app on Vista

Max Diamond

JJustice,

I have the same problem, and if you want to verify a sample that fails on Vista, simply run the following MSDN created sample Remoting app (both client and server):

http://msdn2.microsoft.com/en-us/library/ms973857.aspx

Scroll to the bottom and compile the 3 classes. Note that you'll have to fix the make file that MSDN offers, it is incorrect.

Anyway, it would be great to know what the issue is because I am literally hours away from dumping Vista. It has been an unmitigated disaster in blocking my development efforts, not only on .NET remoting, but in many other areas as well. If you could solve this I would be willing to keep it installed a while longer. I like it otherwise.





Re: .NET Remoting and Runtime Serialization Getting strange error when running a simple remoting app on Vista

John Lambert - MSFT

Everyone, I wrote the below code based on the sample. I was unable to reproduce the issue: I tried the full machine name and "localhost" and both worked on the same machine and from another machine. If the below code doesn't work, please reply with a description of how you launched the program (via Visual Studio, command-line, etc.), the firewall that you're using, the firewall configuration, whether or not there is anything interesting in the Event Log, and the full console output of the below program.

Note: run "RemotingTest.exe /server" in one command window and "RemotingTest.exe /client" in another window. For cross-machine, use "RemotingTest.exe /client servermachinename".

Code Snippet

namespace RemotingTest
{
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting;

public class HelloServer : MarshalByRefObject
{
public HelloServer()
{
Console.WriteLine("HelloServer activated");
}

public String HelloMethod(String name)
{
Console.WriteLine("Hello.HelloMethod : {0}", name);
return "Hi there " + name;
}
}

class Program
{
static readonly bool IsSecured = true;
static string GetInfo()
{
return Environment.UserName + " on " + Environment.MachineName + ", " + Environment.OSVersion + " " + Environment.Version;
}
static void ClientMain(string server)
{
TcpChannel chan = new TcpChannel();
// CHANGE: ensuring security
ChannelServices.RegisterChannel(chan, IsSecured);
string uri = "tcp://" + server + ":8085/SayHello";
Console.WriteLine("Connecting to " + uri);
HelloServer obj = (HelloServer)Activator.GetObject(typeof(HelloServer), uri);
if (obj == null)
{
Console.WriteLine("Could not locate server");
return;
}

string msg = GetInfo();
Console.WriteLine(obj.HelloMethod(msg));
}
public static void ServerMain()
{
TcpChannel chan = new TcpChannel(8085);
// CHANGE: ensuring security
ChannelServices.RegisterChannel(chan, IsSecured);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(HelloServer), "SayHello", WellKnownObjectMode.SingleCall);
Console.WriteLine("Hit <enter> to exit...");
Console.ReadLine();
}
static void Main(string[] args)
{
try
{
Console.WriteLine(GetInfo());
if (args.Length == 0)
{
Console.WriteLine("use /server or /client [servermachinename]");
return;
}
if (args[0] == "/server")
{
ServerMain();
}
else if (args[0] == "/client")
{
string server = "localhost";
if (args.Length == 2)
{
server = args[1];
}
ClientMain(server);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
}