- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
Not another SerializationException
Joined: 25-Apr-2006
Hi,
I'm using Adapter 2.5, VB, SQL Server 2005 and .Net Remoting in a distributed app. The client is a WinForm UI + Service Interface and various support classes. In the middle are the remotable objects with matching interface, all hosted in IIS and I use HTTP.
The problem I have on the face of it looks like the usual Serializable error, but I'm not so sure that it is. In operation, the app runs normally, ie data is fetched as it should be, so long as activity is continuous but if I leave the application untouched for a few minutes then those same data fetches fail with a SerializationException.
Here's the stack trace:
************** Exception Text **************
System.Runtime.Serialization.SerializationException: The input stream is not a valid binary format. The starting contents (in bytes) are: 53-65-72-76-65-72-20-65-6E-63-6F-75-6E-74-65-72-65 ...
Server stack trace:
at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord()
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryResponseMessage(Stream inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
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 ARTEMIS.Interfaces.IMainManager.GetSelectionTreeList(DataTable ComSecTreeList, String entity, Boolean entityState, Byte OutcomeID, Byte Outcome2ID, String HomeDiv)
at ARTEMIS.WIN.frmMain.PopulateTreeList(Byte popOption, String entity, Byte outcome, Byte outcome2)
at ARTEMIS.WIN.frmMain.ShowProjectTreeList(String navBarCaption, Byte filterID, Byte filter2ID)
at ARTEMIS.WIN.frmMain.mnuProjectPCNPrepare_ItemClick(Object sender, ItemClickEventArgs e)
at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarItemLink.OnLinkClick()
at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.BarItemLink.OnLinkActionCore(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
at DevExpress.XtraBars.Controls.CustomLinksControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
and a snip of the MainManager remotable object:
Imports ARTEMIS.Interfaces
Imports ARTEMIS.DAL
Imports ARTEMIS.DAL.EntityClasses
Imports ARTEMIS.DAL.FactoryClasses
Imports ARTEMIS.DAL.HelperClasses
Imports ARTEMIS.DAL.TypedListClasses
Imports ARTEMIS.DAL.DatabaseSpecific
Imports SD.LLBLGen.Pro.ORMSupportClasses
Imports System.Transactions
<Serializable()> _
Public Class MainManager
Inherits MarshalByRefObject
Implements IMainManager
Function GetSelectionTreeList(ByVal ComSecTreeList As DataTable, ByVal entity As String, ByVal entityState As Boolean, ByVal OutcomeID As Byte, ByVal Outcome2ID As Byte, ByVal HomeDiv As String) As DataTable Implements Interfaces.IMainManager.GetSelectionTreeList
...
the matching interface:
Imports ARTEMIS.DAL
Imports ARTEMIS.DAL.EntityClasses
Imports ARTEMIS.DAL.HelperClasses
Imports ARTEMIS.DAL.TypedListClasses
Imports SD.LLBLGen.Pro.ORMSupportClasses
Public Interface IMainManager
Function GetSelectionTreeList(ByVal ComSecTreeList As DataTable, ByVal entity As String, ByVal entityState As Boolean, ByVal OutcomeID As Byte, ByVal Outcome2ID As Byte, ByVal HomeDiv As String) As DataTable
...
All remotable objects are similar. Can anyone help, what could I be missing
Thanks
Please heck whether this thread help you here: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=3533
Joined: 25-Apr-2006
Hi guys, Sorry for the long post.
daelmo wrote:
Please check whether this thread help you here: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=3533
This seems related to a security issue which prevented client data being sent to the server. I am able to both fetch and persist, and its only after a period of inactivity when I try to do a fetch, that I get a failure. It did make me wonder if my configs are correct for remoting.
Here is a snip from the client app.config:
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" useDefaultCredentials="true">
<clientProviders>
<formatter ref="binary"/>
</clientProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
... and Web.Config
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" objectUri="EndPointRegistration.rem" type="ARTEMIS.RemotingService.ServiceRegistration, ARTEMIS.RemotingService"/>
</service>
<channels>
<channel ref="http" useDefaultCredentials="true">
<serverProviders>
<provider ref="wsdl"/>
<formatter ref="binary" typeFilterLevel="Full"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
<system.web>
Otis wrote:
Also do you use a custom fast serialization patch on the ormsupport classes? if so, are client and server both set the fast serialization?
Do you mean
SerializationHelper.Optimization = SerializationOptimization.Fast
On the client I do this after I activate the remote objects and before I register these objects on the server:
Public Sub GetServiceReferences(ByVal ServerName As String)
Dim channel As HttpClientChannel = New HttpClientChannel("HttpBinary", New BinaryClientFormatterSinkProvider())
ChannelServices.RegisterChannel(channel, True)
'Activate the remote objects
Dim ServiceReg As IServiceRegistration = DirectCast(Activator.GetObject(GetType(IServiceRegistration), String.Format(ServerName & "EndPointRegistration.rem")), IServiceRegistration)
frmMain.factoryMainManager = DirectCast(Activator.GetObject(GetType(IMainManagerFactory), String.Format(ServerName & "EndPointMain.rem")), IMainManagerFactory)
...
'Switch on FastSerialization
SerializationHelper.Optimization = SerializationOptimization.Fast
'Register Services/Objects on the server
Call ServiceReg.RegisterObjects()
On the server, I set fast serialization on, in a remotable class after remote service registration as follows:
Public Sub RegisterObjects() Implements Interfaces.IServiceRegistration.RegisterObjects
Dim service1 As Type = Type.GetType("ARTEMIS.RemotingService.MainManagerFactory", True, False)
RemotingConfiguration.RegisterWellKnownServiceType(service1, "EndPointMain.rem", WellKnownObjectMode.SingleCall)
...
' switch on FastSerialization
SerializationHelper.Optimization = SerializationOptimization.Fast
End Sub
One more thought. I set up my references to the service factories that I use, once only in my frmMain as:
'Store references to the service factory objects to avoid having to repeatedly obtain them
Public Shared factoryServiceRegistration As IServiceRegistrationFactory
Public Shared factoryMainManager As IMainManagerFactory
...
Is this likely to cause any issues?
Heres' one of the factories
Public Interface IMainManagerFactory
Function CreateMainManagerInstance() As IMainManager
End Interface
I know there is a lot here but I haven't a clue in which direction to go
Thanks for responding
Most probably IIS is trying to return some text (an http error message, like a 404 or something). But Remoting tries to binary-deserialize the result, which fails.
To see the actual textual error message, either you change the formatter to SoapFormatter. Or use a tcp trace tool to see what is actually going across the wire.
Or use the solution described here: http://www.dotnetconsult.co.uk/weblog/PermaLink.aspx/827189d3-ee0e-444f-b01d-bf9ce9f70f5c
Some relative links: http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-remoting/4585/The-input-stream-is-not-a-valid-binary-format http://blogs.msdn.com/dotnetremoting/archive/2006/06/01/613282.aspx http://forums.lhotka.net/forums/thread/7493.aspx http://geekswithblogs.net/mnf/archive/2007/04/18/Net-remoting-error-The-input-stream-is-not-a-valid.aspx
Joined: 25-Apr-2006
Ok, thanks for all those pointers which I've tried to follow-up on, but with no success - and I'm sweating or is that
I tried the easiest option - the channel sink utility HttpErrorMessageSinkLib. Simple enough to include in my client with provider details in app.config, but it didn't intercept anything and I continue to get the same SerializationException. Has anyone successfully used HttpErrorMessageSinkLib?
So onto the soap formatter; but after converting my service registration routines & the configs, I get a Soap Serializer does not support serializing Generic types. So thats that - back to the binary formatter.
Tried tcptracer but no joy - maybe 'cos I'm using http with a binary formatter!
What's really strange is that on initial access to the system, I can fetch and persist data normally. I only get the SerializationException problem if I leave the application untouched for a few minutes - i.e. if no activity. At which point trying to pass a datatable as an argument to a method in one of the remoting services results in the SerializationException. Yet this same process was used successfully on initial access to the system
Someone mentioned seeing a similar problem reported on a site somewhere but I haven't located it. Has no one experienced anything like this?
Help ...
Joined: 25-Apr-2006
Hi Walaa, thanks for your response.
Looks like others have been here before ( http://osdir.com/ml/windows.devel.dotnet.clr/2004-03/msg00318.html ) though it's a shame they haven't said how they resolved it.
I've managed to identify some useful info from the logs which I'm trying to make sense of. This is the initial access to the app. The posts shown here occur automatically at the start without any user interaction. Initially, the registration seems to fail with an unauthorized access (401) but then followed by an Ok response (200). The 4th post shows another failure followed immediately by an Ok response (looks like a challenge/response dialogue)
13:45:49 W3SVC2 80 POST /ARTEMISRemotingHost/EndPointRegistration.rem - 401 5
13:45:49 W3SVC2 80 POST /ARTEMISRemotingHost/EndPointRegistration.rem - 200 0
13:45:49 W3SVC2 80 POST /ARTEMISRemotingHost/EndPointMain.rem - 200 0
13:45:49 W3SVC2 80 POST /ARTEMISRemotingHost/a75dd89c_6d0c_4535_af23_30f4813c51b8/d3afcleuk0y+xe8k0qc1nu68_375.rem - 401 5
13:45:49 W3SVC2 80 POST /ARTEMISRemotingHost/a75dd89c_6d0c_4535_af23_30f4813c51b8/d3afcleuk0y+xe8k0qc1nu68_375.rem - 200 0
The posts below show the result of user interaction 7 mins after the last successful fetch (200). An unathorized error (401) followed by the generic Internal Server Error (500).
13:46:27 W3SVC2 80 POST /ARTEMISRemotingHost/a75dd89c_6d0c_4535_af23_30f4813c51b8/hletqeh2f66+oaynwhplv_g+_429.rem - 200 0
13:53:59 W3SVC2 80 POST /ARTEMISRemotingHost/a75dd89c_6d0c_4535_af23_30f4813c51b8/d3afcleuk0y+xe8k0qc1nu68_375.rem - 401 5
13:53:59 W3SVC2 80 POST /ARTEMISRemotingHost/a75dd89c_6d0c_4535_af23_30f4813c51b8/d3afcleuk0y+xe8k0qc1nu68_375.rem - 500 0
13:54:15 W3SVC2 80 POST /ARTEMISRemotingHost/a75dd89c_6d0c_4535_af23_30f4813c51b8/d3afcleuk0y+xe8k0qc1nu68_375.rem - 500 0
I'm presuming that this indicates some issue with the credentials, even though I'm using Windows Integrated Security If any one has been here before or have any thoughts I'd be grateful for them.
Thanks
Joined: 25-Apr-2006
Here's specific information about my problem presented as Actions + db Connections (sorry about the lack of formatting).
'Action
'======
'1. Check connection before running application (No of connections = 1)
'2. Start application (No of connections = 2)
'3. Populate treelist (data from datatable via TypedList) (No of connections = 2)
'4. Open a form (data from an EntityCollection) (No of connections = 2)
'5. Check connection after 6 minutes (No of connections = 1)
'6. Open a different form (data from EntityCollection & TypedList (No of connections = 2)
'7. Populate treelist (data from datatable via TypedList) (No of connections still = 2) **SerializationException**
'I then re-ran this to observe the effects of populating the treelist 5 mins after starting the app.
'a. Check connection before running application (No of connections = 1)
'b. Start application (No of connections = 2)
'c. Check connection after 6 minutes (No of connections = 1)
'd. Populate treelist (data from datatable via TypedList) (No of connections = 1) **SerializationException**
At the moment, it appears that at action (7), the connection is not being recognised and at (d) it's not opening a new connection. Both these actions are treelists populated with data sourced from a datatable, filled on the server side by a TypedList.
Are there any known issues with serializing datatables? <EDIT> Using VB?
Would welcome any advice, particularly as datatables are used elsewhere in the app. I'm under the gun on this. Thanks