Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Nigor31-Jul-06 7:08
Nigor31-Jul-06 7:08 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Dustin Metzgar31-Jul-06 8:16
Dustin Metzgar31-Jul-06 8:16 
GeneralRe: How to pass not simple types using .NET Remoting [modified] Pin
Nigor31-Jul-06 8:49
Nigor31-Jul-06 8:49 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Dustin Metzgar31-Jul-06 10:15
Dustin Metzgar31-Jul-06 10:15 
AnswerRe: How to pass not simple types using .NET Remoting [modified] Pin
Andy Brummer31-Jul-06 10:15
sitebuilderAndy Brummer31-Jul-06 10:15 
AnswerRe: How to pass not simple types using .NET Remoting Pin
Nigor31-Jul-06 16:43
Nigor31-Jul-06 16:43 
AnswerRe: How to pass not simple types using .NET Remoting Pin
LongRange.Shooter1-Aug-06 3:36
LongRange.Shooter1-Aug-06 3:36 
AnswerRe: How to pass not simple types using .NET Remoting Pin
Nigor1-Aug-06 5:44
Nigor1-Aug-06 5:44 
Thanks for all your help so far. Conside the following C# 2.0 simple client-server code:

Client:
--------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using System.IO;

namespace RemotingTest
{
class Program
{
static void Main(string[] args)
{
IDictionary properties = new Hashtable();

SoapClientFormatterSinkProvider clientSinkProvider = new SoapClientFormatterSinkProvider();
SoapServerFormatterSinkProvider serverSinkProvider = new SoapServerFormatterSinkProvider();

serverSinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

properties["name"] = "";
properties["port"] = 0;
properties["typeFilterLevel"] = "Full";

HttpChannel httpChannel = new HttpChannel(properties, clientSinkProvider, serverSinkProvider);

ChannelServices.RegisterChannel(httpChannel, false);

RemotingConfiguration.RegisterWellKnownClientType(
typeof(ServerInterface),
"http://igor.no-ip.ca:1024/Server"); // change to appropriate address here

ServerInterface server = new ServerInterface();

string text = "";

while((text = Console.ReadLine()) != "Quit")
{
Console.WriteLine(server.ShowText("testing string"));
Console.WriteLine(server.ShowFileInfo(text).Name);
}

Console.Read();
}
}
}


Server Interface:
------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace RemotingTest
{
public class ServerInterface: MarshalByRefObject
{
public FileInfo ShowFileInfo(string filename)
{
Console.WriteLine("Filename " + filename + " requested");

return new FileInfo(filename);
}

public string ShowText(string text)
{
Console.WriteLine(text);

return "\"" + text + "\" show on the server.";
}
}
}


Server:
-------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

namespace RemotingTest
{
class Program
{
static void Main(string[] args)
{
IDictionary properties = new Hashtable();

SoapServerFormatterSinkProvider serverSinkProvider = new SoapServerFormatterSinkProvider();

serverSinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

properties["name"] = "";
properties["port"] = 1024;
properties["typeFilterLevel"] = "Full";

HttpChannel httpChannel = new HttpChannel(properties, null, serverSinkProvider);
ChannelServices.RegisterChannel(httpChannel, false);

RemotingConfiguration.RegisterWellKnownServiceType(
typeof(ServerInterface),
"Server", WellKnownObjectMode.SingleCall);

Console.Read();
}
}
}


-------------------------------------------------------------------------
The above sample would work no problem if you launch the server and client on the same machine. However, move them across machine boundries and you will find that passing a string and getting a response from server.ShowText() works, but the client will give you an exception after 30 sec. or so trying to execute server.ShowFileInfo();

To test the programs, enter properly formatted filenames, like "C:\test.txt" or something in the client and if you want to quit, type in "Quit". The filename does not have to exist, it just has to have proper format.

For you convinience, i zipped up VS2005 solution here: http://igor.no-ip.ca/remoting%20test.zip

Thanks!
GeneralRe: How to pass not simple types using .NET Remoting Pin
Dustin Metzgar1-Aug-06 5:58
Dustin Metzgar1-Aug-06 5:58 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Nigor1-Aug-06 6:09
Nigor1-Aug-06 6:09 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Dustin Metzgar1-Aug-06 6:19
Dustin Metzgar1-Aug-06 6:19 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Nigor1-Aug-06 6:32
Nigor1-Aug-06 6:32 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Dustin Metzgar1-Aug-06 7:00
Dustin Metzgar1-Aug-06 7:00 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Nigor1-Aug-06 8:22
Nigor1-Aug-06 8:22 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Dustin Metzgar1-Aug-06 8:46
Dustin Metzgar1-Aug-06 8:46 
GeneralRe: How to pass not simple types using .NET Remoting Pin
Nigor1-Aug-06 11:03
Nigor1-Aug-06 11:03 
AnswerRe: How to pass not simple types using .NET Remoting [modified] Pin
Nigor3-Aug-06 9:23
Nigor3-Aug-06 9:23 
AnswerRe: How to pass not simple types using .NET Remoting [modified] Pin
Nigor4-Aug-06 8:03
Nigor4-Aug-06 8:03 
GeneralRe: How to pass not simple types using .NET Remoting Pin
code-frog4-Aug-06 8:21
professionalcode-frog4-Aug-06 8:21 
GeneralRe: How to pass not simple types using .NET Remoting [modified] Pin
Nigor4-Aug-06 9:10
Nigor4-Aug-06 9:10 
GeneralRe: How to pass not simple types using .NET Remoting Pin
code-frog4-Aug-06 14:46
professionalcode-frog4-Aug-06 14:46 
GeneralRe: How to pass not simple types using .NET Remoting [modified] Pin
Nigor5-Aug-06 3:18
Nigor5-Aug-06 3:18 
QuestionDataGridView Button w/ Image Pin
swcrissman31-Jul-06 5:13
swcrissman31-Jul-06 5:13 
QuestionInstance from the active form Pin
Ramez Quneibi31-Jul-06 4:31
Ramez Quneibi31-Jul-06 4:31 
AnswerRe: Instance from the active form Pin
Judah Gabriel Himango31-Jul-06 5:12
sponsorJudah Gabriel Himango31-Jul-06 5:12 

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.