Discussion:
Problems using 1.1 BinaryFormatter from ASP.Net 2.0 web applicatio
(too old to reply)
dethomps
2006-09-26 14:31:02 UTC
Permalink
Hi,

I've encountered a problem with a cross-firewall Remoting application which
uses a BinaryFormatter. The application was built with Framework 1.1 and
works fine when accessed from 1.1 applications, but throws the following
exception when accessed from a framework 2.0 application:

Error Source :mscorlib

Error Stack Trace :
Server stack trace:
at System.Runtime.Remoting.Channels.Tcp.TcpReadingStream.Flush()
at System.Security.Cryptography.CryptoStream.FlushFinalBlock()
at System.Security.Cryptography.CryptoStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at DMZSender.DMZSenderLib.GetDataView(String SQL, String tableName,
String[] aliasArgs)
at COL.Security.SecurityManager.GetDataView(String sql, String tableName,
String[] aliasArgs)
at TestTiming.WebForm1.Page_Load(Object sender, EventArgs e)

Error TargetSite :Void
HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage,
System.Runtime.Remoting.Messaging.


Any suggestions are appreciated.
d***@revq.com
2006-11-11 00:20:16 UTC
Permalink
I have the exact same problem. Have you had any luck in solving the issue?
---
Posted via DotNetSlackers.com
dethomps
2006-11-17 18:55:37 UTC
Permalink
Post by d***@revq.com
I have the exact same problem. Have you had any luck in solving the issue?
---
Posted via DotNetSlackers.com
Unfortunately, I never solved the problem, even with extensive
assistance from Microsoft. The problem occurs inside of an
EncryptionSink DLL which we had copied from the Ingo Rammer Advanced
.Net Remoting book (as have many others).

What seems to happen is that the calling application invokes the
remoting stack as a 2.0 application, but the reply comes back as a 1.1
application. The calling application appears to load the 2.0 version
of System.Runtime.Remoting.Channels.Tcp, but the reply seems to invoke
the 1.1 version when it tries to decrypt the response. The 2.0 version
of the TcpReadingStream object no longer provides a Flush method, but
the 1.1 version did. So I get the "Method not found" exception.

While working on this problem I found out that Microsoft has provided
native support for encryption if you use 2.0 Remoting, so I'm just
going to sidestep the whole problem and do that. It allows me to get
rid of the EncryptionSink.

Of course this last approach creates a new problem which is that you
need to be able to authenticate the user who originates the remoting
request, which is not possible from the DMZ, if you want to use
encryption. Oh well ...
Joe
2010-07-27 05:24:51 UTC
Permalink
Try using this in ProcessInboundStream function....
public static Stream ProcessInboundStream(Stream InStream, string Algorithm, byte[] EncryptionKey, byte[] EncryptionIV)
{
SymmetricAlgorithm Alg = SymmetricAlgorithm.Create(Algorithm);
Alg.BlockSize = 64;
Alg.Key = EncryptionKey;
Alg.IV = EncryptionIV;

Stream OutStream = new CryptoStream(InStream, Alg.CreateDecryptor(), CryptoStreamMode.Read);

MemoryStream DecryptedStream = new MemoryStream();
byte[] Buffer = new byte[1000];
int BytesRead;
while ((BytesRead = OutStream.Read(Buffer, 0, Buffer.Length)) > 0)
{
DecryptedStream.Write(Buffer, 0, BytesRead);
}

OutStream.Close();
InStream.Close();

DecryptedStream.Seek(0, SeekOrigin.Begin);

return DecryptedStream;


From http://www.developmentnow.com/g/24_2006_9_0_0_826869/Problems-using-1-1-BinaryFormatter-from-ASP-Net-2-0-web-applicatio.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/

Loading...