Returning a FileStream over a remoting connection

Here's the scenario:

I have many PC's on my network, and I need to programmatically pull files off of each one. I have a windows service that is hosting a remoting object (using TCP Channels).

From my main PC I am able to successfully get files if I return them from the remoting object as a byte array. However, when I return a FileStream I get a connection error. Here is a snippet:

FileStream tmps = remoteObject.getFileStream(@"C:\test.txt");

MessageBox.Show(tmps.Length.ToString()); < this is the line that fails with the error: "System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it."

Now the odd part is, if I run that same remote object in a windows service on my local machine it works fine. Am I missing something here?

If this was your scenario, could you think of a better way of doing it? My issue is these files are quite large (150-2000 MB). Returning them as a byte array from the remote object is causing a lot of memory issues. If I could return a filestream then I can process the file in chunks so the entire file is never in memory.

[1370 byte] By [TylerFrugia] at [2007-12-23]
# 1

See also http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=596400&SiteID=1. It should work eventually, but you shouldn't do this with remoting if you can help it. You can use Windows shares, HTTP or FTP. They are better suited for transferring files over the network.

LucianBargaoanu at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Remoting and Runtime Serialization...

.NET Development

Site Classified