Click here to Skip to main content
15,909,747 members
Home / Discussions / C#
   

C#

 
GeneralRe: Ctrl-C with error Pin
sirovsky18-Aug-03 3:02
sirovsky18-Aug-03 3:02 
GeneralRe: Ctrl-C with error Pin
A.Wegierski19-Aug-03 19:20
A.Wegierski19-Aug-03 19:20 
GeneralRe: Ctrl-C with error Pin
Ista18-Aug-03 5:58
Ista18-Aug-03 5:58 
GeneralWhat's the point of Remoting if you need to "Add Reference" Pin
devvvy17-Aug-03 22:20
devvvy17-Aug-03 22:20 
GeneralRe: What's the point of Remoting if you need to "Add Reference" Pin
James T. Johnson18-Aug-03 3:27
James T. Johnson18-Aug-03 3:27 
GeneralRe: What's the point of Remoting if you need to "Add Reference" Pin
devvvy18-Aug-03 5:20
devvvy18-Aug-03 5:20 
GeneralRe: What's the point of Remoting if you need to "Add Reference" Pin
James T. Johnson18-Aug-03 5:44
James T. Johnson18-Aug-03 5:44 
GeneralRe: What's the point of Remoting if you need to "Add Reference" Pin
devvvy18-Aug-03 6:51
devvvy18-Aug-03 6:51 
Thanks. But I'm having some trouble separating interface with remote class. Calls to:

SERVER SIDE:
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(nsCRemoteObj.CRemoteObj), //QUESTION 1: I still need to reference the remote object - as opposed to the interface??
"CRemoteObjURI",
WellKnownObjectMode.SingleCall //QUESTION 2: Since we'll be communicating with client via "interface", NO Singleton?
);

AND

CLIENT SIDE:

IRemoteObj obj = (IRemoteObj) Activator.GetObject(
typeof(CRemoteObj), //QUESTION 3: Opps, I still to reference the remote object assembly - in addition to interface assembly!??
"http://localhost:8085/CRemoteObjURI"
);

Any idea?





**********************************************************************
code structure below if you're interested. (Questions are highlited --> "QUESTION"):

(1) my remote object source file (CRemoteObj.cs) (dll):

using nsCRemoteObjInterface; //For IRemoteObj interface.

namespace nsCRemoteObj
{
public class CRemoteObj : System.MarshalByRefObject, IRemoteObj
{
... some stuff ...
}
}

Then, "add reference" to reference the interface assembly (CRemoteObjInterface.cs).

(2) Interface assembly (CRemoteObjInterface.cs) (dll):

using System;

namespace nsCRemoteObjInterface
{
public interface IRemoteObj : IMarshal
{
bool AuthenticateLoser(string sUserName, string sPasswd);

};
}

Nothing needs to be referenced from interface assembly.

(3) Server "CRemoteObjServer.cs" (exe):

{

[STAThread]
static void Main(string[] args)
{
//Register channel:
TcpServerChannel tcpchannel = new TcpServerChannel(8086);
ChannelServices.RegisterChannel(tcpchannel);

HttpServerChannel httpchannel = new HttpServerChannel(8085);
ChannelServices.RegisterChannel(httpchannel);

//Register TYPE:
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(nsCRemoteObj.CRemoteObj), //QUESTION 1: I still need to reference the remote object - as opposed to the interface??
"CRemoteObjURI",
WellKnownObjectMode.SingleCall //QUESTION 2: Since we'll be communicating with client via "interface", NO Singleton?
);

Console.WriteLine("CRemoteServer started and listening on tcp(8086) and http(8085).");
Console.WriteLine("Hit any key to exit.");
Console.WriteLine();

Console.ReadLine();

}

(4) Client "CRemoteObjClient.cs" (exe):

using nsCRemoteObj; //QUESTION 3: Still need to reference remote object assembly in addition to interface assembly...
using nsCRemoteObjInterface;

namespace nsCRemoteObjClient
{
class CRemoteObjClient
{
[STAThread]
static void Main(string[] args)
{
//Register channel:
ChannelServices.RegisterChannel( new HttpChannel() );


try
{
//Retrieve remote object proxy (WellKnown object - server-activated SingleCall):
IRemoteObj obj = (IRemoteObj) Activator.GetObject(
typeof(CRemoteObj),
"http://localhost:8085/CRemoteObjURI"
);

//Invoke function thru proxy:
Console.WriteLine("CRemoteObjClient: Client side invoke.");
bool bAuthStatus = false;
for(int i=0; i<3; i++)
{
bAuthStatus = obj.AuthenticateLoser("Paul", "12345");
Console.WriteLine("i={0}, bAuthStatus: {1}", i.ToString(), bAuthStatus);
}

}
catch(Exception err)
{
Console.WriteLine("Exception: {0}", err.ToString());
}

}
}
}

norm
GeneralRe: What's the point of Remoting if you need to "Add Reference" Pin
James T. Johnson18-Aug-03 11:27
James T. Johnson18-Aug-03 11:27 
GeneralRe: What's the point of Remoting if you need to &quot;Add Reference&quot; Pin
devvvy18-Aug-03 15:07
devvvy18-Aug-03 15:07 
GeneralRe: What's the point of Remoting if you need to &quot;Add Reference&quot; Pin
James T. Johnson18-Aug-03 15:26
James T. Johnson18-Aug-03 15:26 
GeneralRe: What's the point of Remoting if you need to &quot;Add Reference&quot; Pin
devvvy18-Aug-03 18:05
devvvy18-Aug-03 18:05 
QuestionWhere r the Shape and Line Controls??? Pin
pShay17-Aug-03 21:43
pShay17-Aug-03 21:43 
AnswerRe: Where r the Shape and Line Controls??? Pin
Sascha Andres17-Aug-03 23:27
Sascha Andres17-Aug-03 23:27 
AnswerRe: Where r the Shape and Line Controls??? Pin
Ista18-Aug-03 16:59
Ista18-Aug-03 16:59 
Generalexposing remoting from ASP.NET Pin
devvvy17-Aug-03 20:37
devvvy17-Aug-03 20:37 
Question&quot;as&quot; keyword in C#? Pin
devvvy17-Aug-03 20:06
devvvy17-Aug-03 20:06 
AnswerRe: &quot;as&quot; keyword in C#? Pin
Roger Alsing17-Aug-03 20:10
Roger Alsing17-Aug-03 20:10 
AnswerRe: &quot;as&quot; keyword in C#? Pin
J. Dunlap17-Aug-03 20:17
J. Dunlap17-Aug-03 20:17 
GeneralRe: &quot;as&quot; keyword in C#? Pin
devvvy17-Aug-03 20:39
devvvy17-Aug-03 20:39 
AnswerRe: &quot;as&quot; keyword in C#? Pin
Russell Morris18-Aug-03 4:30
Russell Morris18-Aug-03 4:30 
GeneralRe: &quot;as&quot; keyword in C#? Pin
devvvy18-Aug-03 5:11
devvvy18-Aug-03 5:11 
GeneralMy Network Places Pin
Nick Seng17-Aug-03 17:04
Nick Seng17-Aug-03 17:04 
GeneralRe: My Network Places Pin
Mazdak17-Aug-03 19:48
Mazdak17-Aug-03 19:48 
GeneralRe: My Network Places Pin
Nick Seng17-Aug-03 20:02
Nick Seng17-Aug-03 20:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.