Remoting 101 - a.k.a Brain Fart

Remoting 101 - a.k.a Brain Fart

Old forum URL:

honus posted on Wednesday, September 10, 2008

After getting remoting working in my WinForms application, I still have a question or two.  First, I noticed that some of my objects are successfully using remoting, and some are still trying to run locally.  For example, I have a NameValueListBase object that is NOT using remoting, but I want it to:

<Serializable()> _
Public Class webServiceNVL
Inherits NameValueListBase(Of Guid, String)

Public Shared Function getList(ByVal showDealUrlsOnly As Boolean, Optional ByVal showFriendlyName As Boolean = True) As webServiceNVL
   Return New webServiceNVL(showDealUrlsOnly, showFriendlyName)
End Function

Private Sub New(ByVal showDealUrlsOnly As Boolean, ByVal showFriendlyName As Boolean)
   Using cn As New SqlConnection(Database.MainConnection)
Using cm As SqlCommand = cn.CreateCommand
With cm
               .CommandType = CommandType.StoredProcedure
               .CommandText =
.Parameters.AddWithValue("@onlyShowDealWebServices", showDealUrlsOnly)

               Using dr As New SafeDataReader(.ExecuteReader)
                  IsReadOnly =
With dr
While .Read()
Me.Add(New NameValuePair(.GetGuid("webServiceID"), .GetString("webServiceFriendlyName")))
End While
End With
IsReadOnly = True
End Using
End With
   End Using
   End Using
End Sub

Is this because I am not using a DataPortal.Fetch method, which would force it to use the remote DataPortal identified in the app.config of the WinForms application?  Are there better CSLA references out there, in regards to Remoting, than the few pages in the book?

Thanks in advance!

Michael Hildner replied on Wednesday, September 10, 2008

Yeah, you're going to want to use DataPortal_Fetch so the data portal can do whatever you configure it to do. I haven't looked in a while, but I'm guessing there's an example in Project Tracker you can look at - I can also post a sample NVL I have, but all my bo's are in C#. Let me know if you want to see one.

I'm not aware of any CSLA references out there in regards to remoting, besides the book. There's tons of stuff on remoting, though. Of course CSLA just uses remoting (if you tell it to).




honus replied on Wednesday, September 10, 2008

Thank you.  I found the RoleList object in ProjectTracker, which inherits from NameValueListBase.  It correctly uses the DataPortal.Fetch:

Public Shared Function GetList() As RoleList

If mList Is Nothing Then
mList = DataPortal.Fetch(Of RoleList)(New Criteria(GetType(RoleList)))
End If

Return mList

End Function

Copyright (c) Marimer LLC