Connection trough MarshalByRefObject

  • Thread starter Thread starter Krys
  • Start date Start date
K

Krys

When i invoke a method (which tries to create a database query) from
client on server, server throws COMException.

this code is in dll used by server and client:
public class zdalne_objekty : MarshalByRefObject
{
public string testowa()
{
Recordset wynik = new Recordset();
SqlConnection conn = new SqlConnection("User ID=sa;Initial
Catalog=test;Data Source=KRYSW\\INSERTGT;Packet Size=4096;Workstation
ID=KRYSW");
wynik.Open("SELECT * FROM tabelka", conn,
ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockUnspecified,8);
return "test";
}

code from client:
TcpChannel c = new TcpChannel();
ChannelServices.RegisterChannel(c, true);

object zdalny_objekt =
Activator.GetObject(typeof(zdalne_objekty), "tcp://localhost:10500/Objekt
zdalny.tcp");
zdalne_objekty zdal = (zdalne_objekty)zdalny_objekt;
string ds = zdal.testowa();


when i use method testowa() local on serwer, everything works fine.
what is wrong? why doesnt it work from client trough network?
 
RecordSet? Do you use ADO (the old COM object)? Why?

OK, if you insist using ADO, rather than ADO.NET for your special reason,
that is fine. However, you cannot use ADO.NET's SqlConnection object for
opening ADODB.RecordSet. You need a ADODB.Connection.



When i invoke a method (which tries to create a database query) from
client on server, server throws COMException.

this code is in dll used by server and client:
public class zdalne_objekty : MarshalByRefObject
{
public string testowa()
{
Recordset wynik = new Recordset();
SqlConnection conn = new SqlConnection("User ID=sa;Initial
Catalog=test;Data Source=KRYSW\\INSERTGT;Packet Size=4096;Workstation
ID=KRYSW");
wynik.Open("SELECT * FROM tabelka", conn,
ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockUnspecified,8);
return "test";
}

code from client:
TcpChannel c = new TcpChannel();
ChannelServices.RegisterChannel(c, true);

object zdalny_objekt =
Activator.GetObject(typeof(zdalne_objekty), "tcp://localhost:10500/Objekt
zdalny.tcp");
zdalne_objekty zdal = (zdalne_objekty)zdalny_objekt;
string ds = zdal.testowa();


when i use method testowa() local on serwer, everything works fine.
what is wrong? why doesnt it work from client trough network?
 
RecordSet? Do you use ADO (the old COM object)? Why?

OK, if you insist using ADO, rather than ADO.NET for your special reason,
that is fine. However, you cannot use ADO.NET's SqlConnection object for
opening ADODB.RecordSet. You need a ADODB.Connection.

I used ADODB.Connection too, works either not.
Second if i run this code local from server (not remote from client) it
works fine...
 
Back
Top