469,625 Members | 1,078 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

Problem with .NET remote

Hey guys I saw you have a lot of experiance in .net remoting so I am having a problem. I am getting a Requested Service Not Found error when I try to run a remote function. For this I use the following code for my Remote Class
Expand|Select|Wrap|Line Numbers
  1. Partial Public Class clsSQL
  2.     Inherits MarshalByRefObject
  3.     Dim DisSqlConn As SqlConnection
  4.  
  5.     Sub main()
  6.         Dim channel As TcpServerChannel = New TcpServerChannel(1234)
  7.         ChannelServices.RegisterChannel(channel, False)
  8.     End Sub
  9.     Public Function connectToDB()
  10.         Dim sysInfo As New clsConnection
  11.         Dim sqlUserName As String
  12.         Dim sqlPassWord As String
  13.         Dim SqlConnString As String
  14.         'set Username and Password for SQL Connection
  15.         sqlUserName = sysInfo.SQLUserName
  16.         sqlPassWord = sysInfo.SQLPassWord
  17.  
  18.         'initialize connection string
  19.         SqlConnString = "server=dissql;uid=" + sqlUserName + ";pwd=" + sqlPassWord + ";database=dis"
  20.         DisSqlConn = New SqlConnection(SqlConnString)
  21.  
  22.         'open the connection string
  23.         Try
  24.             DisSqlConn.Open()
  25.         Catch ex As Exception
  26.             Dim errorString As String = "error: "
  27.             errorString = errorString + ex.Message
  28.             MsgBox(errorString, MsgBoxStyle.Critical, )
  29.         End Try
  30.  
  31.     End Function
  32.     Public Function getCaseScreenInfo(ByVal caseNumber As String) As String()
  33.         Dim caseCommand As SqlCommand
  34.         Dim caseString As String
  35.         Dim drCase As SqlDataReader = Nothing
  36.  
  37.  
  38.         Me.connectToDB()
  39.         caseString = "select CASE_RECORD.CASE_NUMBER,CASE_RECORD.CASE_DESCRIPTION," _
  40.         & "CASE_RECORD.CASE_STATUS_CODE,CASE_RECORD.CASE_INDUSTRY_CODE," _
  41.         & "CASE_RECORD.CASE_PURPOSE_CODE,CASE_RECORD.CASE_OPENED_DATE," _
  42.         & "CASE_RECORD.CASE_DATE_CLOSED from dbo.CASE_RECORD" _
  43.         & " where CASE_RECORD.CASE_NUMBER='" & caseNumber & "'"
  44.         caseCommand = New SqlCommand(caseString, DisSqlConn)
  45.         Try
  46.             drCase = caseCommand.ExecuteReader()
  47.         Catch ex As Exception
  48.             MsgBox(ex.Message)
  49.         End Try
  50.         Dim caseValues(drCase.FieldCount) As String
  51.         If drCase.HasRows Then
  52.             While drCase.Read
  53.                 Dim i As Integer = drCase.FieldCount
  54.                 Dim i2 As Integer = 0
  55.                 While i >= 1
  56.                     caseValues(i2) = drCase(i2)
  57.                     i = i - 1
  58.                     i2 = i2 + 1
  59.                 End While
  60.  
  61.             End While
  62.             Return caseValues
  63.         End If
  64.     End Function
  65.  
  66.     Public Function closeDB()
  67.         Try
  68.             DisSqlConn.Close()
  69.             DisSqlConn = Nothing
  70.         Catch ex As Exception
  71.             MsgBox("error: " + ex.Message, MsgBoxStyle.OkOnly, )
  72.         End Try
  73.     End Function
  74. End Class
  75.  
and this for my listener
Expand|Select|Wrap|Line Numbers
  1. Imports System.Runtime.Remoting
  2. Imports System.Runtime.Remoting.Channels
  3. Imports System.Runtime.Remoting.Channels.Tcp
  4. Imports DISCLSV100
  5. Module modRemoteConn
  6.  
  7.     Sub Main()
  8.  
  9.         Dim channel As TcpServerChannel = New TcpServerChannel(49152)
  10.         ChannelServices.RegisterChannel(channel, False)
  11.         RemotingConfiguration.RegisterWellKnownServiceType(GetType(DISCLSV100.clsSQL), "clsSQL", WellKnownObjectMode.SingleCall)
  12.  
  13.  
  14.         Console.WriteLine("Server Started")
  15.         Console.WriteLine("Hit <enter> to quit")
  16.         Console.ReadLine()
  17.  
  18.     End Sub
  19.  
  20. End Module
and my call looks like this
Expand|Select|Wrap|Line Numbers
  1. Dim childCases As New frmCases
  2.             Dim caseChannel As TcpClientChannel = New TcpClientChannel()
  3.             ChannelServices.RegisterChannel(caseChannel, False)
  4.             RemotingConfiguration.RegisterWellKnownClientType(GetType(clsSQL), "tcp://jackie:49152/dbconnect")
  5.  
  6.             dbc = New clsSQL
  7.             Dim information() As String
  8.             information = dbc.getCaseScreenInfo(Me.mtxtCaseNum.Text)
  9.  
any ideas?

thanks Jackie
Apr 26 '06 #1
1 1466
Please Ignore I am a Moron and had the wrong TCP address
Apr 26 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by John | last post: by
reply views Thread by Suresh | last post: by
1 post views Thread by Mr. Beck | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.