When passing a large byte array as a parameter to a remote method, I get the following error:
System.Runtime.Serialization.SerializationException: The input stream is not a valid binary format. The starting contents (in bytes) are: 53-79-73-74-65-6D-2E-57-65-62-2E-48-74-74-70-45-78 ... Server stack trace: at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input)... etc.
The largest byte array I can successfully pass across the wire is 4,193,890 elements in size, as soon as I go to 4,193,891 it bombs out with the above exception.
I am running the .NET Framework 2.0 Beta 2. The server is a singleton object hosted inside IIS 6.0 running on Windows Server 2003, using the Http channel with the Binary formatter. The client is a Windows Forms application running on Windows XP.
The same error occurs if I pass a large string as a parameter instead of a byte array, so the problem seems to be with the size of the parameter instead of the type.
Any chance this should should be reported to Microsoft, or am I just doing something silly here... thanks for any help! :-)

Error passing a large variable as a parameter to a remote method
Rogdie
What connection timeout settings do you have set
deacon
Can you show me an example with this problem is fixed Thank you.
Andrei Plinda
skyover
I've discovered that the the actual exception was be obfuscated by the SerializationException (the old problem of attempting to deserialize XML text as binary data)... in any case the actual exception is this:
IOException: An established connection was aborted by the software in your host machine
I'm not sure what software would be aborting the connection. So there's something else going on here.
Andrero
4096 is the default maxRequestLength for an ASP.NET request to a server. this is the most probable cause...
you can change this behavior in your config file.
<configuration>
<system.web>
<httpRuntime>
also,
Large Data Strategies
http://whidbey.msdn.microsoft.com/library/default.asp url=/library/en-us/dnservice/html/service11072001.asp
Uploading Files Using the File Field Control
http://whidbey.msdn.microsoft.com/library/default.asp url=/library/en-us/dnaspp/html/aspnet-fileupload.asp
a search on maxRequestLength yields a handful of others.
Nathalieg23
Here's my workaround (though it lacks a bit from a performance perspective) -- I instantiate a MarshalByRefObject on the server which hosts an ArrayList. Then I feed the byte array to the remote object in chunks. The object is then passed to my remote method which knows how to reconstruct the original byte array from the ArrayList.
I can't seem to find any information on this exception ("The input stream is not a valid binary format"). A google search turns up nothing, and neither does MSDN.
Ranga Krishnan
I so much need your help here.
I have a simple application ... and its going to get big :) if i figure out the .NET remoting part.
It just wont work.
Its based on configuration files. I use VS 2005 - .NET 2.0 - IIS 6.0 to host the remoting objects and a simple Form GUI to test. I use binary format.
thats the code :
web.config - server :
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" objectUri="Mail.rem" type="RemotingServer.MailManager, RemotingServer" />
</service>
<channels>
<channel ref="http">
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
client - app.config
<system.runtime.remoting>
<application name="clientUI">
<client url="http://xxxxxxxx:8000/RemoteIIS/Mail.rem" type="RemotingServer.MailManager, RemotingServer">
</client>
<channels>
<channel ref="http">
<clientProviders>
<formatter ref="binary"/>
</clientProviders>
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full"/>
</serverProviders>
</channel>
</channels>
</application>
and thats is the code of my client (an onlick handler) :
Try
Dim configFilePath As String = System.IO.Path.Combine(System.Environment.CurrentDirectory, "ClientUI.exe.config")
RemotingConfiguration.Configure(configFilePath, False)
'1.
'Dim service As RemotingServer.Mailmanager = New RemotingServer.Mailmanager()
'2.
'Dim service As RemotingServer.Mailmanager = CType(Activator.GetObject(GetType(RemotingServer.Mailmanager), "http://pdsintranet:8000/RemoteIIS/Mail.rem"), RemotingServer.Mailmanager)
'3.
Dim o As Object = RemotingServices.Connect(GetType(RemotingServer.Mailmanager), "http://pdsintranet:8000/RemoteIIS/Mail.rem")
Dim service As RemotingServer.Mailmanager = CType(o, RemotingServer.Mailmanager)
Debug.Print(RemotingServices.IsTransparentProxy(service))
Debug.Print(service.getCompName())
'Me.Mail1.Merge(service.GetEmails())
Catch eX As Exception
Debug.Write(eX.StackTrace())
End Try
if i try to get the Mailmanager object by the 1st way : i get the local copy!!!
with the 2nd and 3rd ways i get the error you discuss on this thread : Invalid Binary Format etc..
I would really appreciate your help.
Thanks in advance
rEaXX
I can send a copy of the VS2005 solution I used to replicate the problem. Please let me know if you would like a copy.
Thanks for any help :-)
Alexander Dsugan
TaylorClark
DellS
Stupid me did this (the class was wrapped in a namespace) and couldn't work out why I was getting this.
The joys of programming!
????
I've also discovered that this error also occurs when attempting to send a MarshalByRefObject to a method of a remote object. I definitely would not expect a SerializationException to occur in this case, since a MarshalByRefObject should not be serialized (and I have not marked the class as [Serializable] either).