I’ve created a BO inheriting from ReadOnlyListBase which works fine locally but is throwing an error when using remoting. I suspect it might have something to do with me using a List(Of T) as an argument in the Criteria constructor. All the other BOs in the project are loading correctly, but none of them has a List(Of T) as a Criteria argument.
At the moment I'm testing on a single box, so the 'remote' computer also has the client on it.
The calling function looks like:
Public Shared Function objWebPagesLookupReadOnlyFetch(ByVal intWebsiteD As Int32) As WebPagesLookupReadOnly
Dim objSqlParameterList As New List(Of SqlParameter)
Dim objSqlParameter As New SqlParameter("@intWebsiteID", SqlDbType.Int)
objSqlParameter.Value = intWebsiteD
objSqlParameterList.Add(objSqlParameter)
Dim objCriteria As New Criteria("StoredProcedureName", objSqlParameterList)
Return DataPortal.objFetch(Of WebPagesLookupReadOnly)(objCriteria)
End Function
In the data access section of the BO, the error (according to line number in the stack trace) is on the Add line below, though it might be in the first line:
For Each objSqlParameter In objCriteria.objSqlParameterList
objSqlCommand.Parameters.Add(objSqlParameter)
Next
Not being expert in remote debugging, I'm having difficulty in finding out what actual values have been transferred to the 'remote' computer.
I had a look at this thread: http://forums.lhotka.net/forums/thread/8929.aspx. Whilst similar, it doesn't seem to be quite the same.
Can anyone shed any light on this?
Many thanks.
Crispin
Andrés
The inner exception is not giving anything away - it just says the DataPortal Fetch method failed.
I did some checking around the web as to whether SqlParameter was serializable or not and found nothing definitive. So I wrote a small console app to see if it worked or not:
Sub Main() Dim objListOfSqlParameter As New List(Of SqlParameter) Dim objSqlParameter As New SqlParameter("@storedproc", SqlDbType.Int)objListOfSqlParameter.Add(objSqlParameter)
Console.WriteLine(
"Serializing...") Dim objSerializer As New Serialization.XmlSerializer(GetType(List(Of SqlParameter))) Dim objStreamWriter As New StreamWriter("D:\SqlParameterList.xml")objSerializer.Serialize(objStreamWriter, objListOfSqlParameter)
objStreamWriter.Close()
Console.WriteLine(
"Deserializing...") Dim objSerializer2 As New Serialization.XmlSerializer(GetType(List(Of SqlParameter))) Dim objListOfSqlParameter2 As New List(Of SqlParameter) Dim objFileStream As New FileStream("D:\SqlParameterList.xml", FileMode.Open)objListOfSqlParameter2 =
DirectCast(objSerializer2.Deserialize(objFileStream), List(Of SqlParameter))Console.WriteLine(
"Done")Console.ReadLine()
End SubThis works, so it looks like a List(Of SqlParameter) can be serialized.
Thanks anyway.
Crispin
I did find this message at the top of the trace:
System.Runtime.Remoting.RemotingException: This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.
Initially I ignored this because all the other BOs (before and after this was was invoked) worked perfectly. I took it to mean that there was an error, but the error message wasn't relevant - but someone else may think differently.
Crispin
The data portal doesn't use the XmlSerializer. As I discuss in the book, it doesn't provide the capabilities required to serialize object graphs completely. The BinaryFormatter is what is used, and that's what you'd need to use for testing.
Look at the DoClone() implementation discussed in Chapter 3 for some sample code along this line.
That will be your simplest test scheme too - directly run the BinaryFormatter on your Criteria class and see if it can be serialized/deserialized successfully.
So much for using the XML serializer so as to be able to look at the output half-way.
I find it odd that the XML serializer works and the binary one doesn't; odder still that SqlParameter is 'not marked marked as serializable' according to the error message on the binary formatter when it clearly works for the XML serializer. Oh, well.
Thanks for your help guys.
Crispin
Copyright (c) Marimer LLC