[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Adam Snider

7/21/2004 2:51:00 AM

I have a class (in a class library) that opens a database connection and
returns a connection object. I have a reference to this class library in my
server code and my client code. I tried inheriting marshalbyreference in
the database class, but when I ran the client-side code it wanted to open
the database from the client instead of from the server. For example, the
client was trying to look for the specified path to the database that was
used in my database class and of course could not find the path because the
path only existed on the server. Should I be using marshalbyvalue instead
for this class? If so, how do I instantiate it on the server.....before I
was doing the following:

'Server code snippet
dim vendor as Vendor
RemotingServices.Marshal(vendor, "Vendor")

Any suggestions would be greatly appreciated.

Thanks,
Adam


18 Answers

Sunny

7/21/2004 6:14:00 AM

0

Hi Adam,

Your problem starts with some configuration error and your client is not
receiving a sever reference, but creates a local object. Thats why the
client tries to connect to the DB. I highly recommend using interface or
abstract class shared assembly as better solution (see below). That way for
sure you will know that you do not reach the server.

As well I do not thing that this is a good idea to pass a connection object
to the client. If I create a simple program, using your shared assembly, I
can easily get the connection string (which may contain username and
password) to your db. I would rather create a wrapper, which accepts a
client call and queries the database itself.

Also, shipping your server assembly with the client is not good as well.
Disassembling is so easy these days.

Allen Anderson has a good article here:

http://www.glacialcomponents.com/ArticleDetail.aspx?articleID=Re...

Cheers
Sunny


Adam Snider wrote:

> I have a class (in a class library) that opens a database connection and
> returns a connection object. I have a reference to this class library in
> my
> server code and my client code. I tried inheriting marshalbyreference in
> the database class, but when I ran the client-side code it wanted to open
> the database from the client instead of from the server. For example, the
> client was trying to look for the specified path to the database that was
> used in my database class and of course could not find the path because
> the
> path only existed on the server. Should I be using marshalbyvalue instead
> for this class? If so, how do I instantiate it on the server.....before I
> was doing the following:
>
> 'Server code snippet
> dim vendor as Vendor
> RemotingServices.Marshal(vendor, "Vendor")
>
> Any suggestions would be greatly appreciated.
>
> Thanks,
> Adam

Adam Snider

7/21/2004 8:59:00 AM

0

Sunny,

Thanks for your reply. I am new to this so I have to take things one step
at a time! You mentioned there might be some configuration error.....what
do you mean by that? I've added some code below.....do you see anything
wrong with it?

Here is the class library code:





"Sunny" <sunny@newsgroups.nospam> wrote in message
news:en2mtnubEHA.212@TK2MSFTNGP12.phx.gbl...
> Hi Adam,
>
> Your problem starts with some configuration error and your client is not
> receiving a sever reference, but creates a local object. Thats why the
> client tries to connect to the DB. I highly recommend using interface or
> abstract class shared assembly as better solution (see below). That way
for
> sure you will know that you do not reach the server.
>
> As well I do not thing that this is a good idea to pass a connection
object
> to the client. If I create a simple program, using your shared assembly, I
> can easily get the connection string (which may contain username and
> password) to your db. I would rather create a wrapper, which accepts a
> client call and queries the database itself.
>
> Also, shipping your server assembly with the client is not good as well.
> Disassembling is so easy these days.
>
> Allen Anderson has a good article here:
>
> http://www.glacialcomponents.com/ArticleDetail.aspx?articleID=Re...
>
> Cheers
> Sunny
>
>
> Adam Snider wrote:
>
> > I have a class (in a class library) that opens a database connection and
> > returns a connection object. I have a reference to this class library
in
> > my
> > server code and my client code. I tried inheriting marshalbyreference
in
> > the database class, but when I ran the client-side code it wanted to
open
> > the database from the client instead of from the server. For example,
the
> > client was trying to look for the specified path to the database that
was
> > used in my database class and of course could not find the path because
> > the
> > path only existed on the server. Should I be using marshalbyvalue
instead
> > for this class? If so, how do I instantiate it on the server.....before
I
> > was doing the following:
> >
> > 'Server code snippet
> > dim vendor as Vendor
> > RemotingServices.Marshal(vendor, "Vendor")
> >
> > Any suggestions would be greatly appreciated.
> >
> > Thanks,
> > Adam
>


Adam Snider

7/21/2004 9:13:00 AM

0

Oops, I didn't get to finish that message.....I've included the code I'm
working with. Do you see any configuration errors?

Thanks,
Adam

Here is the class library code:

Imports Advantage.Data.Provider
Public Class PayablesDB
Inherits System.MarshalByRefObject
Public Shared Function GetPayablesConnection() As AdsConnection
Dim conn As New AdsConnection("Data Source =
\\Adam\databases\Payables.add; User ID = ADSSYS; TableType = ADT; ServerType
= LOCAL; TrimTrailingSpaces = TRUE")
Return conn
End Function
End Class

Imports Advantage.Data.Provider
Public Class VendorsDB
Inherits PayablesDB
Public Shared Function GetAllVendors() As DataSet
Dim sSqlCommand = "Select * " _
& "From Vendors"
Dim conPayables As AdsConnection = GetPayablesConnection()
Dim daVendors As New AdsDataAdapter(sSqlCommand, conPayables)
Dim dsVendors As New DataSet
daVendors.Fill(dsVendors)
Return dsVendors
End Function
Public Shared Function GetVendorNames() As DataSet
Dim sSqlCommand = "Select VendorID, VendorName " _
& "From Vendors Order By VendorName"
Dim conPayables As AdsConnection = GetPayablesConnection()
Dim daVendors As New AdsDataAdapter(sSqlCommand, conPayables)
Dim dsVendors As New DataSet
daVendors.Fill(dsVendors, "VendorNames")
Return dsVendors
End Function
Public Shared Function GetStates() As DataSet
Dim sSqlCommand = "Select StateCode, StateName " _
& "From States Order By StateName"
Dim conPayables As AdsConnection = GetPayablesConnection()
Dim daStates As New AdsDataAdapter(sSqlCommand, conPayables)
Dim dsStates As New DataSet
daStates.Fill(dsStates, "States")
Return dsStates
End Function
Public Shared Function GetVendor(ByVal VendorID As Integer) As Vendor
Dim Vendor As New Vendor
Dim drVendor As AdsDataReader
Dim conPayables As AdsConnection = GetPayablesConnection()
conPayables.Open()
Dim sSqlCommand = "Select VendorID, VendorName, VendorAddress1, " _
& "VendorAddress2, VendorCity, VendorState, VendorZipCode " _
& "From Vendors Where VendorID = :VendorID"
Dim cmdVendors As New AdsCommand(sSqlCommand, conPayables)
cmdVendors.Parameters.Add(":VendorID", VendorID)
drVendor = cmdVendors.ExecuteReader(CommandBehavior.SingleRow)
If drVendor.Read Then
Vendor.ID = drVendor("VendorID")
Vendor.Name = drVendor("VendorName")
Vendor.Address1 = drVendor("VendorAddress1").ToString
Vendor.Address2 = drVendor("VendorAddress2").ToString
Vendor.City = drVendor("VendorCity")
Vendor.State = drVendor("VendorState")
Vendor.ZipCode = drVendor("VendorZipCode")
Else
Vendor = Nothing
End If
conPayables.Close()
Return Vendor
End Function

Public Class Vendor
Inherits System.MarshalByRefObject
Private sName As String
Private sCity As String
Private sState As String
Private sZipCode As String
Public ID As Integer
Public Property Name() As String
Get
Return sName
End Get
Set(ByVal Value As String)
If Value = "" Then
Throw New ArgumentOutOfRangeException("Name required.")
Else
sName = Value
End If
End Set
End Property
Public Address1 As String
Public Address2 As String
Public Property City() As String
Get
Return sCity
End Get
Set(ByVal Value As String)
If Value = "" Then
Throw New ArgumentOutOfRangeException("City required.")
Else
sCity = Value
End If
End Set
End Property
Public Property State() As String
Get
Return sState
End Get
Set(ByVal Value As String)
If Value = "" Then
Throw New ArgumentOutOfRangeException("State required.")
Else
sState = Value
End If
End Set
End Property
Public Property ZipCode() As String
Get
Return sZipCode
End Get
Set(ByVal Value As String)
If Value = "" Then
Throw New ArgumentOutOfRangeException("ZipCode required.")
Else
sZipCode = Value
End If
End Set
End Property
End Class





Here is the server code:

Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Tcp
Imports DatabaseClass
Module StartupMod
Sub main()
Console.WriteLine("ExhangeHost started")
Dim prop As IDictionary = New Hashtable(3)
prop("name") = "Remoting"
prop("port") = 10000
prop("machineName") = "192.168.1.102"
Dim channel As New TcpChannel(prop, Nothing, Nothing)
ChannelServices.RegisterChannel(channel)
Dim payablesDb As New PayablesDB
RemotingServices.Marshal(payablesDb, "PayablesDB")
Dim vendorsDb As New VendorsDB
RemotingServices.Marshal(vendorsDb, "VendorsDB")
Dim vendor As New Vendor
RemotingServices.Marshal(vendor, "Vendor")
Console.ReadLine()
End Sub
End Module




Finally, the client code, just the form load:


Imports System.Runtime.Remoting
Imports DatabaseClass
Public Class Form1
Inherits System.Windows.Forms.Form
Dim bLoading As Boolean
Dim bNewVendor As Boolean
Dim url1 As String = "tcp://67.163.111.197:10000/PayablesDB"
Dim PayablesDB As DatabaseClass.PayablesDB =
CType(RemotingServices.Connect(GetType(PayablesDB), url1), PayablesDB)
Dim url2 As String = "tcp://67.163.111.197:10000/VendorsDB"
Dim VendorsDB As DatabaseClass.VendorsDB =
CType(RemotingServices.Connect(GetType(VendorsDB), url2), VendorsDB)
Dim url3 As String = "tcp://67.163.111.197:10000/Vendor"
Dim Vendor As DatabaseClass.Vendor =
CType(RemotingServices.Connect(GetType(Vendor), url3), Vendor)
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dsStates As DataSet
dsStates = VendorsDB.GetStates()
cboStates.DataSource = dsStates.Tables("States")
cboStates.DisplayMember = "StateName"
cboStates.ValueMember = "StateCode"
bLoading = True
Me.RefreshVendors()
Me.ShowVendor(cboVendors.SelectedValue)
Me.SetMaintenanceButtons(True)
bLoading = False
End Sub









"Sunny" <sunny@newsgroups.nospam> wrote in message
news:en2mtnubEHA.212@TK2MSFTNGP12.phx.gbl...
> Hi Adam,
>
> Your problem starts with some configuration error and your client is not
> receiving a sever reference, but creates a local object. Thats why the
> client tries to connect to the DB. I highly recommend using interface or
> abstract class shared assembly as better solution (see below). That way
for
> sure you will know that you do not reach the server.
>
> As well I do not thing that this is a good idea to pass a connection
object
> to the client. If I create a simple program, using your shared assembly, I
> can easily get the connection string (which may contain username and
> password) to your db. I would rather create a wrapper, which accepts a
> client call and queries the database itself.
>
> Also, shipping your server assembly with the client is not good as well.
> Disassembling is so easy these days.
>
> Allen Anderson has a good article here:
>
> http://www.glacialcomponents.com/ArticleDetail.aspx?articleID=Re...
>
> Cheers
> Sunny
>
>
> Adam Snider wrote:
>
> > I have a class (in a class library) that opens a database connection and
> > returns a connection object. I have a reference to this class library
in
> > my
> > server code and my client code. I tried inheriting marshalbyreference
in
> > the database class, but when I ran the client-side code it wanted to
open
> > the database from the client instead of from the server. For example,
the
> > client was trying to look for the specified path to the database that
was
> > used in my database class and of course could not find the path because
> > the
> > path only existed on the server. Should I be using marshalbyvalue
instead
> > for this class? If so, how do I instantiate it on the server.....before
I
> > was doing the following:
> >
> > 'Server code snippet
> > dim vendor as Vendor
> > RemotingServices.Marshal(vendor, "Vendor")
> >
> > Any suggestions would be greatly appreciated.
> >
> > Thanks,
> > Adam
>


Allen Anderson

7/21/2004 2:56:00 PM

0

are you using a shared assembly with an intermediate object? Sunny is
absolutely right in his assesment that you are creating the object
locally for some reason due to a configuration problem. The best way
to make sure that doesn't happen is to (as he says) use an interface
or abstract class as the ref class so that its not possible to create
it locally without it going through proxy.

Cheers,
Allen Anderson
http://www.glacialcomp...
mailto: allen@put my website base here.com

On Wed, 21 Jul 2004 02:13:06 -0700, "Adam Snider"
<adam.snider@comcast.net> wrote:

>Oops, I didn't get to finish that message.....I've included the code I'm
>working with. Do you see any configuration errors?
>
>Thanks,
>Adam
>
>Here is the class library code:
>
>Imports Advantage.Data.Provider
>Public Class PayablesDB
> Inherits System.MarshalByRefObject
> Public Shared Function GetPayablesConnection() As AdsConnection
> Dim conn As New AdsConnection("Data Source =
>\\Adam\databases\Payables.add; User ID = ADSSYS; TableType = ADT; ServerType
>= LOCAL; TrimTrailingSpaces = TRUE")
> Return conn
> End Function
>End Class
>
>Imports Advantage.Data.Provider
>Public Class VendorsDB
>Inherits PayablesDB
>Public Shared Function GetAllVendors() As DataSet
> Dim sSqlCommand = "Select * " _
> & "From Vendors"
> Dim conPayables As AdsConnection = GetPayablesConnection()
> Dim daVendors As New AdsDataAdapter(sSqlCommand, conPayables)
> Dim dsVendors As New DataSet
> daVendors.Fill(dsVendors)
> Return dsVendors
>End Function
>Public Shared Function GetVendorNames() As DataSet
> Dim sSqlCommand = "Select VendorID, VendorName " _
> & "From Vendors Order By VendorName"
> Dim conPayables As AdsConnection = GetPayablesConnection()
> Dim daVendors As New AdsDataAdapter(sSqlCommand, conPayables)
> Dim dsVendors As New DataSet
> daVendors.Fill(dsVendors, "VendorNames")
> Return dsVendors
>End Function
>Public Shared Function GetStates() As DataSet
> Dim sSqlCommand = "Select StateCode, StateName " _
> & "From States Order By StateName"
> Dim conPayables As AdsConnection = GetPayablesConnection()
> Dim daStates As New AdsDataAdapter(sSqlCommand, conPayables)
> Dim dsStates As New DataSet
> daStates.Fill(dsStates, "States")
> Return dsStates
>End Function
>Public Shared Function GetVendor(ByVal VendorID As Integer) As Vendor
> Dim Vendor As New Vendor
> Dim drVendor As AdsDataReader
> Dim conPayables As AdsConnection = GetPayablesConnection()
> conPayables.Open()
> Dim sSqlCommand = "Select VendorID, VendorName, VendorAddress1, " _
> & "VendorAddress2, VendorCity, VendorState, VendorZipCode " _
> & "From Vendors Where VendorID = :VendorID"
> Dim cmdVendors As New AdsCommand(sSqlCommand, conPayables)
> cmdVendors.Parameters.Add(":VendorID", VendorID)
> drVendor = cmdVendors.ExecuteReader(CommandBehavior.SingleRow)
> If drVendor.Read Then
> Vendor.ID = drVendor("VendorID")
> Vendor.Name = drVendor("VendorName")
> Vendor.Address1 = drVendor("VendorAddress1").ToString
> Vendor.Address2 = drVendor("VendorAddress2").ToString
> Vendor.City = drVendor("VendorCity")
> Vendor.State = drVendor("VendorState")
> Vendor.ZipCode = drVendor("VendorZipCode")
> Else
> Vendor = Nothing
> End If
> conPayables.Close()
> Return Vendor
>End Function
>
>Public Class Vendor
> Inherits System.MarshalByRefObject
> Private sName As String
> Private sCity As String
> Private sState As String
> Private sZipCode As String
> Public ID As Integer
> Public Property Name() As String
> Get
> Return sName
> End Get
> Set(ByVal Value As String)
> If Value = "" Then
> Throw New ArgumentOutOfRangeException("Name required.")
> Else
> sName = Value
> End If
> End Set
> End Property
>Public Address1 As String
>Public Address2 As String
>Public Property City() As String
> Get
> Return sCity
> End Get
> Set(ByVal Value As String)
> If Value = "" Then
> Throw New ArgumentOutOfRangeException("City required.")
> Else
> sCity = Value
> End If
> End Set
>End Property
>Public Property State() As String
> Get
> Return sState
> End Get
> Set(ByVal Value As String)
> If Value = "" Then
> Throw New ArgumentOutOfRangeException("State required.")
> Else
> sState = Value
> End If
> End Set
>End Property
>Public Property ZipCode() As String
> Get
> Return sZipCode
> End Get
> Set(ByVal Value As String)
> If Value = "" Then
> Throw New ArgumentOutOfRangeException("ZipCode required.")
> Else
> sZipCode = Value
> End If
> End Set
>End Property
>End Class
>
>
>
>
>
>Here is the server code:
>
>Imports System.Runtime.Remoting
>Imports System.Runtime.Remoting.Channels
>Imports System.Runtime.Remoting.Channels.Tcp
>Imports DatabaseClass
>Module StartupMod
> Sub main()
> Console.WriteLine("ExhangeHost started")
> Dim prop As IDictionary = New Hashtable(3)
> prop("name") = "Remoting"
> prop("port") = 10000
> prop("machineName") = "192.168.1.102"
> Dim channel As New TcpChannel(prop, Nothing, Nothing)
> ChannelServices.RegisterChannel(channel)
> Dim payablesDb As New PayablesDB
> RemotingServices.Marshal(payablesDb, "PayablesDB")
> Dim vendorsDb As New VendorsDB
> RemotingServices.Marshal(vendorsDb, "VendorsDB")
> Dim vendor As New Vendor
> RemotingServices.Marshal(vendor, "Vendor")
> Console.ReadLine()
> End Sub
>End Module
>
>
>
>
>Finally, the client code, just the form load:
>
>
>Imports System.Runtime.Remoting
>Imports DatabaseClass
>Public Class Form1
> Inherits System.Windows.Forms.Form
> Dim bLoading As Boolean
> Dim bNewVendor As Boolean
> Dim url1 As String = "tcp://67.163.111.197:10000/PayablesDB"
> Dim PayablesDB As DatabaseClass.PayablesDB =
>CType(RemotingServices.Connect(GetType(PayablesDB), url1), PayablesDB)
> Dim url2 As String = "tcp://67.163.111.197:10000/VendorsDB"
> Dim VendorsDB As DatabaseClass.VendorsDB =
>CType(RemotingServices.Connect(GetType(VendorsDB), url2), VendorsDB)
> Dim url3 As String = "tcp://67.163.111.197:10000/Vendor"
> Dim Vendor As DatabaseClass.Vendor =
>CType(RemotingServices.Connect(GetType(Vendor), url3), Vendor)
> Private Sub Form1_Load(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> Dim dsStates As DataSet
> dsStates = VendorsDB.GetStates()
> cboStates.DataSource = dsStates.Tables("States")
> cboStates.DisplayMember = "StateName"
> cboStates.ValueMember = "StateCode"
> bLoading = True
> Me.RefreshVendors()
> Me.ShowVendor(cboVendors.SelectedValue)
> Me.SetMaintenanceButtons(True)
> bLoading = False
> End Sub
>
>
>
>
>
>
>
>
>
>"Sunny" <sunny@newsgroups.nospam> wrote in message
>news:en2mtnubEHA.212@TK2MSFTNGP12.phx.gbl...
>> Hi Adam,
>>
>> Your problem starts with some configuration error and your client is not
>> receiving a sever reference, but creates a local object. Thats why the
>> client tries to connect to the DB. I highly recommend using interface or
>> abstract class shared assembly as better solution (see below). That way
>for
>> sure you will know that you do not reach the server.
>>
>> As well I do not thing that this is a good idea to pass a connection
>object
>> to the client. If I create a simple program, using your shared assembly, I
>> can easily get the connection string (which may contain username and
>> password) to your db. I would rather create a wrapper, which accepts a
>> client call and queries the database itself.
>>
>> Also, shipping your server assembly with the client is not good as well.
>> Disassembling is so easy these days.
>>
>> Allen Anderson has a good article here:
>>
>> http://www.glacialcomp.../ArticleDetail.aspx?articleID=RemoteObject
>>
>> Cheers
>> Sunny
>>
>>
>> Adam Snider wrote:
>>
>> > I have a class (in a class library) that opens a database connection and
>> > returns a connection object. I have a reference to this class library
>in
>> > my
>> > server code and my client code. I tried inheriting marshalbyreference
>in
>> > the database class, but when I ran the client-side code it wanted to
>open
>> > the database from the client instead of from the server. For example,
>the
>> > client was trying to look for the specified path to the database that
>was
>> > used in my database class and of course could not find the path because
>> > the
>> > path only existed on the server. Should I be using marshalbyvalue
>instead
>> > for this class? If so, how do I instantiate it on the server.....before
>I
>> > was doing the following:
>> >
>> > 'Server code snippet
>> > dim vendor as Vendor
>> > RemotingServices.Marshal(vendor, "Vendor")
>> >
>> > Any suggestions would be greatly appreciated.
>> >
>> > Thanks,
>> > Adam
>>
>

Sunny

7/21/2004 3:30:00 PM

0

In article <ulHfZ#ubEHA.3480@TK2MSFTNGP11.phx.gbl>,
adam.snider@comcast.net says...
> Sunny,
>
> Thanks for your reply. I am new to this so I have to take things one step
> at a time! You mentioned there might be some configuration error.....what
> do you mean by that? I've added some code below.....do you see anything
> wrong with it?
>
> Here is the class library code:
>
>

Hi Adam,

I see the problem. All your public functions and properties are declared
Shared (static in c#).

The the static members are not remoted. So, your client creates its own
static members to server its own VendorDB class.

Actually you do not need the make them Shared, as by using Marshal() you
are creating SAO Singleton, I.e. all clients will access only this
instance.

So, I see another problem there too. If you expose the Vendor class with
Marshal(), you make it SAO Singleton as well. So all clients will share
the same object. Is this what you want? If so, then you have to put some
efforts to make it thread safe. Every remoting call is executed on a
different thread. So what will happen, if one client tries to set lets
say City property, and in the same time another client tries the same
and a third client tries to read it. Which write will succeed? and as
you do not have control of how threads are executed, actually on thread
can start to write in the private var, and just in the middle the system
may give execution to another thread, which will start writing as well,
but your private var is in unknown state already. And not, if the system
(without finishing the second write as well) gives the reading thread
execution right, what will it read? Something really unusable.

Take a look here to learn more about threads and multythreading
applications. The examples are in c#, but you will figure it out.

http://www.yoda.arachsys.com/csharp/multithre...

Sunny

Sunny

7/21/2004 5:10:00 PM

0

In article <OJXESP0bEHA.2812@tk2msftngp13.phx.gbl>,
adam.snider@comcast.net says...
> Sunny,
>
> Thank you very much for all your help. I went ahead and removed shared from
> all the functions in my database class library, but I got an error when I
> ran the code:
>
> An unhandled exception of type 'System.Runtime.Remoting.RemotingException'
> occurred in mscorlib.dll
>
> Did you see anything else that might have caused this?
>
> Thanks,
> Adam
>

Yes, you have to set typeFilterLevel = Full.

Read my replay to Harry's post "Remoting and security limit
problem,help", posted on 8/20.

Sunny

Sunny

7/21/2004 6:01:00 PM

0

You have to set it both at the server and at the client.

Also, you have to set customErrors = off for the server to really see
what is the exception.

customErrors can be set only in a config files. Ahh, well there is an
ugly hack to do it programmatically, but I do not recommend to do this.

So, create a simple text file with the following content:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.runtime.remoting>
<customErrors mode="off"/>
</system.runtime.remoting>

</configuration>

Place this file in your server directory and after you register the
channels in your server code, invoke:

RemotingConfiguration.Configure("myfile.xml");

This will enable exceptions to be rethrown to the client.

Sunny

In article <ueLpgp0bEHA.2352@TK2MSFTNGP09.phx.gbl>,
adam.snider@comcast.net says...
> Well, added in the following code and I still got the same error:
>
> Dim serverProv = New BinaryServerFormatterSinkProvider
> serverProv.TypeFilterLevel = TypeFilterLevel.Full
> Dim clientProvider = New BinaryClientFormatterSinkProvider
>
> Dim prop As IDictionary = New Hashtable(3)
> prop("name") = "Remoting"
> prop("port") = 10000
> prop("machineName") = "192.168.1.102"
> Dim channel As New TcpChannel(prop, clientProvider, serverProv)
> ChannelServices.RegisterChannel(channel)
>
> This is the error message....
>
> An unhandled exception of type 'System.Runtime.Remoting.RemotingException'
> occurred in mscorlib.dll
> Additional information: Server encountered an internal error. For more
> information, turn on customErrors in the server's .config file.
>
> Thanks,
> Adam
>
>
> "Sunny" <sunny@newsgroups.nospam> wrote in message
> news:OUibcW0bEHA.556@tk2msftngp13.phx.gbl...
> > In article <OJXESP0bEHA.2812@tk2msftngp13.phx.gbl>,
> > adam.snider@comcast.net says...
> > > Sunny,
> > >
> > > Thank you very much for all your help. I went ahead and removed shared
> from
> > > all the functions in my database class library, but I got an error when
> I
> > > ran the code:
> > >
> > > An unhandled exception of type
> 'System.Runtime.Remoting.RemotingException'
> > > occurred in mscorlib.dll
> > >
> > > Did you see anything else that might have caused this?
> > >
> > > Thanks,
> > > Adam
> > >
> >
> > Yes, you have to set typeFilterLevel = Full.
> >
> > Read my replay to Harry's post "Remoting and security limit
> > problem,help", posted on 8/20.
> >
> > Sunny
>
>
>

Adam Snider

7/21/2004 7:02:00 PM

0

Sunny,

Thank you very much for all your help. I went ahead and removed shared from
all the functions in my database class library, but I got an error when I
ran the code:

An unhandled exception of type 'System.Runtime.Remoting.RemotingException'
occurred in mscorlib.dll

Did you see anything else that might have caused this?

Thanks,
Adam

Additional information: Server encountered an internal error. For more
information, turn on customErrors in the server's .config file.
"Sunny" <sunny@newsgroups.nospam> wrote in message
news:OQYAGezbEHA.2408@tk2msftngp13.phx.gbl...
> In article <ulHfZ#ubEHA.3480@TK2MSFTNGP11.phx.gbl>,
> adam.snider@comcast.net says...
> > Sunny,
> >
> > Thanks for your reply. I am new to this so I have to take things one
step
> > at a time! You mentioned there might be some configuration
error.....what
> > do you mean by that? I've added some code below.....do you see anything
> > wrong with it?
> >
> > Here is the class library code:
> >
> >
>
> Hi Adam,
>
> I see the problem. All your public functions and properties are declared
> Shared (static in c#).
>
> The the static members are not remoted. So, your client creates its own
> static members to server its own VendorDB class.
>
> Actually you do not need the make them Shared, as by using Marshal() you
> are creating SAO Singleton, I.e. all clients will access only this
> instance.
>
> So, I see another problem there too. If you expose the Vendor class with
> Marshal(), you make it SAO Singleton as well. So all clients will share
> the same object. Is this what you want? If so, then you have to put some
> efforts to make it thread safe. Every remoting call is executed on a
> different thread. So what will happen, if one client tries to set lets
> say City property, and in the same time another client tries the same
> and a third client tries to read it. Which write will succeed? and as
> you do not have control of how threads are executed, actually on thread
> can start to write in the private var, and just in the middle the system
> may give execution to another thread, which will start writing as well,
> but your private var is in unknown state already. And not, if the system
> (without finishing the second write as well) gives the reading thread
> execution right, what will it read? Something really unusable.
>
> Take a look here to learn more about threads and multythreading
> applications. The examples are in c#, but you will figure it out.
>
> http://www.yoda.arachsys.com/csharp/multithre...
>
> Sunny


Adam Snider

7/21/2004 7:22:00 PM

0

Unfortunately, I'm new to the news group and the earliest date I can go back
to is 6/7/2004. I'll try setting that to full and see what happens.

Thanks alot for all your help!!!!
Adam

"Sunny" <sunny@newsgroups.nospam> wrote in message
news:OUibcW0bEHA.556@tk2msftngp13.phx.gbl...
> In article <OJXESP0bEHA.2812@tk2msftngp13.phx.gbl>,
> adam.snider@comcast.net says...
> > Sunny,
> >
> > Thank you very much for all your help. I went ahead and removed shared
from
> > all the functions in my database class library, but I got an error when
I
> > ran the code:
> >
> > An unhandled exception of type
'System.Runtime.Remoting.RemotingException'
> > occurred in mscorlib.dll
> >
> > Did you see anything else that might have caused this?
> >
> > Thanks,
> > Adam
> >
>
> Yes, you have to set typeFilterLevel = Full.
>
> Read my replay to Harry's post "Remoting and security limit
> problem,help", posted on 8/20.
>
> Sunny


Adam Snider

7/21/2004 7:49:00 PM

0

Well, added in the following code and I still got the same error:

Dim serverProv = New BinaryServerFormatterSinkProvider
serverProv.TypeFilterLevel = TypeFilterLevel.Full
Dim clientProvider = New BinaryClientFormatterSinkProvider

Dim prop As IDictionary = New Hashtable(3)
prop("name") = "Remoting"
prop("port") = 10000
prop("machineName") = "192.168.1.102"
Dim channel As New TcpChannel(prop, clientProvider, serverProv)
ChannelServices.RegisterChannel(channel)

This is the error message....

An unhandled exception of type 'System.Runtime.Remoting.RemotingException'
occurred in mscorlib.dll
Additional information: Server encountered an internal error. For more
information, turn on customErrors in the server's .config file.

Thanks,
Adam


"Sunny" <sunny@newsgroups.nospam> wrote in message
news:OUibcW0bEHA.556@tk2msftngp13.phx.gbl...
> In article <OJXESP0bEHA.2812@tk2msftngp13.phx.gbl>,
> adam.snider@comcast.net says...
> > Sunny,
> >
> > Thank you very much for all your help. I went ahead and removed shared
from
> > all the functions in my database class library, but I got an error when
I
> > ran the code:
> >
> > An unhandled exception of type
'System.Runtime.Remoting.RemotingException'
> > occurred in mscorlib.dll
> >
> > Did you see anything else that might have caused this?
> >
> > Thanks,
> > Adam
> >
>
> Yes, you have to set typeFilterLevel = Full.
>
> Read my replay to Harry's post "Remoting and security limit
> problem,help", posted on 8/20.
>
> Sunny