[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

convert console app to config file?

Greg

10/18/2004 2:25:00 PM

The following code successfully turns an existing assembly into a server
object to which my client app successfully connects and invokes a method
from the server object.

TcpServerChannel channel = new TcpServerChannel(8086);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
i",WellKnownObjectMode.SingleCall)

System.Console.WriteLine("hit to exit");
System.Console.ReadLine();

Can I create a config file out of these few lines of code?

thank you. -hazz






8 Answers

Sam Santiago

10/18/2004 3:34:00 PM

0

Yes, how about:

<system.runtime.remoting>
<application name="MyRemoteServer">
<service>
<wellknown mode="SingleCall"
type="Namespace.ServerClass, AssemblyName"
objectUri="MyURI">
</service>
<channels>
<channel ref="tcp" port="8086">
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full" />
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>

The client side configuration file is left as an exercise for the reader
;-).

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"hazz" <hazz@sonic.net> wrote in message
news:%233OkC5RtEHA.4044@TK2MSFTNGP09.phx.gbl...
> The following code successfully turns an existing assembly into a server
> object to which my client app successfully connects and invokes a method
> from the server object.
>
> TcpServerChannel channel = new TcpServerChannel(8086);
> ChannelServices.RegisterChannel(channel);
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
> i",WellKnownObjectMode.SingleCall)
>
> System.Console.WriteLine("hit to exit");
> System.Console.ReadLine();
>
> Can I create a config file out of these few lines of code?
>
> thank you. -hazz
>
>
>
>
>
>


Ken Kolda

10/18/2004 3:46:00 PM

0

I'm not 100% sure of what you're asking. The configuration performed by the
first three lines could certainly be placed in a config file, e.g.

<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="tcp" port="8086" />
</channels>
<server>
<wellknown mode="SingleCall" type="ServerClass, ServerAssembly"
objectUri="MyUri" />
</server>
</application>
</system.runtime.remoting>
</configuration>

The last two, of course, could not -- they are application code and not
configuration. Are you asking if it's possible to use an assembly as a
remote object without writing a host application and simply using a config
file? If so, the answer is no, although you can achieve essentialy something
like this by using IIS as your host (i.e. this would mean you wouldn't have
to write your own host app).

Ken


"hazz" <hazz@sonic.net> wrote in message
news:%233OkC5RtEHA.4044@TK2MSFTNGP09.phx.gbl...
> The following code successfully turns an existing assembly into a server
> object to which my client app successfully connects and invokes a method
> from the server object.
>
> TcpServerChannel channel = new TcpServerChannel(8086);
> ChannelServices.RegisterChannel(channel);
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
> i",WellKnownObjectMode.SingleCall)
>
> System.Console.WriteLine("hit to exit");
> System.Console.ReadLine();
>
> Can I create a config file out of these few lines of code?
>
> thank you. -hazz
>
>
>
>
>
>


Greg

10/18/2004 4:35:00 PM

0

Thank you Sam.
Actually I have an operational hurdle.
I created a working sample of a client and server in VS.NET using the code I
provided.
If I create the configuration file as you very helpfully morphed for me, how
do I activate the server object? In VS.NET I just had to click Start-F54
and everything automagically happened. The console commands gave me instant
feedback the service was running.
If I use a config file....well how do I kick start the remoted object in
question.How do I know it's up and running and available for service? Sorry
for these I am sure painfully obvious questions.
Thanks again. I am getting closer!
hazz
"Sam Santiago" <ssantiago@n0spam-SoftiTechture.com> wrote in message
news:ubY30fStEHA.3200@TK2MSFTNGP14.phx.gbl...
> Yes, how about:
>
> <system.runtime.remoting>
> <application name="MyRemoteServer">
> <service>
> <wellknown mode="SingleCall"
> type="Namespace.ServerClass, AssemblyName"
> objectUri="MyURI">
> </service>
> <channels>
> <channel ref="tcp" port="8086">
> <serverProviders>
> <formatter ref="binary" typeFilterLevel="Full" />
> </serverProviders>
> </channel>
> </channels>
> </application>
> </system.runtime.remoting>
>
> The client side configuration file is left as an exercise for the reader
> ;-).
>
> Thanks,
>
> Sam
>
> --
> _______________________________
> Sam Santiago
> ssantiago@n0spam-SoftiTechture.com
> http://www.SoftiTe...
> _______________________________
> "hazz" <hazz@sonic.net> wrote in message
> news:%233OkC5RtEHA.4044@TK2MSFTNGP09.phx.gbl...
> > The following code successfully turns an existing assembly into a server
> > object to which my client app successfully connects and invokes a method
> > from the server object.
> >
> > TcpServerChannel channel = new TcpServerChannel(8086);
> > ChannelServices.RegisterChannel(channel);
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
> > i",WellKnownObjectMode.SingleCall)
> >
> > System.Console.WriteLine("hit to exit");
> > System.Console.ReadLine();
> >
> > Can I create a config file out of these few lines of code?
> >
> > thank you. -hazz
> >
> >
> >
> >
> >
> >
>
>


Greg

10/18/2004 4:44:00 PM

0

Actually Ken you guessed my dilemna. I was told by the "remoting resource"
where I am working that all I have to do is add a config file to the
existing codebase and presto, as long as I have MarshalByRefObj, then I am
off and running.
You are saying that I do indeed need a host application? Or host in IIS?
Is the host application then what kickstarts the process? So the host
application is either an .exe that one has to manually execute, or it
becomes a service...or it is hosted in IIS in which case the client's call
to a specific URI contained in the server's web config file launches the
process?
Thank you for seeing my confusion and asking the question.
hazz

"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
news:uzGw2mStEHA.160@TK2MSFTNGP11.phx.gbl...
> I'm not 100% sure of what you're asking. The configuration performed by
the
> first three lines could certainly be placed in a config file, e.g.
>
> <configuration>
> <system.runtime.remoting>
> <application>
> <channels>
> <channel ref="tcp" port="8086" />
> </channels>
> <server>
> <wellknown mode="SingleCall" type="ServerClass, ServerAssembly"
> objectUri="MyUri" />
> </server>
> </application>
> </system.runtime.remoting>
> </configuration>
>
> The last two, of course, could not -- they are application code and not
> configuration. Are you asking if it's possible to use an assembly as a
> remote object without writing a host application and simply using a config
> file? If so, the answer is no, although you can achieve essentialy
something
> like this by using IIS as your host (i.e. this would mean you wouldn't
have
> to write your own host app).
>
> Ken
>
>
> "hazz" <hazz@sonic.net> wrote in message
> news:%233OkC5RtEHA.4044@TK2MSFTNGP09.phx.gbl...
> > The following code successfully turns an existing assembly into a server
> > object to which my client app successfully connects and invokes a method
> > from the server object.
> >
> > TcpServerChannel channel = new TcpServerChannel(8086);
> > ChannelServices.RegisterChannel(channel);
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
> > i",WellKnownObjectMode.SingleCall)
> >
> > System.Console.WriteLine("hit to exit");
> > System.Console.ReadLine();
> >
> > Can I create a config file out of these few lines of code?
> >
> > thank you. -hazz
> >
> >
> >
> >
> >
> >
>
>


Sam Santiago

10/18/2004 4:52:00 PM

0

You can create a VS 2003 Solution that has two projects within in it - your
client project and your server project. Add a Applicaton Configuration file
to each project - app.config. Place the remoting configuration parameters
within the app.config file. Start your server application (console app most
likely) by right clicking on it and choosing Debug, Start Instance. Start
your client application next by right clicking on it and choosing Debug,
Step Into. You can find an example on my site,
http://www.SoftiTe.../d..., regarding the factory pattern with
remoting.

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"hazz" <hazz@sonic.net> wrote in message
news:ev%23$vBTtEHA.3572@tk2msftngp13.phx.gbl...
> Thank you Sam.
> Actually I have an operational hurdle.
> I created a working sample of a client and server in VS.NET using the code
I
> provided.
> If I create the configuration file as you very helpfully morphed for me,
how
> do I activate the server object? In VS.NET I just had to click Start-F54
> and everything automagically happened. The console commands gave me
instant
> feedback the service was running.
> If I use a config file....well how do I kick start the remoted object in
> question.How do I know it's up and running and available for service?
Sorry
> for these I am sure painfully obvious questions.
> Thanks again. I am getting closer!
> hazz
> "Sam Santiago" <ssantiago@n0spam-SoftiTechture.com> wrote in message
> news:ubY30fStEHA.3200@TK2MSFTNGP14.phx.gbl...
> > Yes, how about:
> >
> > <system.runtime.remoting>
> > <application name="MyRemoteServer">
> > <service>
> > <wellknown mode="SingleCall"
> > type="Namespace.ServerClass, AssemblyName"
> > objectUri="MyURI">
> > </service>
> > <channels>
> > <channel ref="tcp" port="8086">
> > <serverProviders>
> > <formatter ref="binary" typeFilterLevel="Full" />
> > </serverProviders>
> > </channel>
> > </channels>
> > </application>
> > </system.runtime.remoting>
> >
> > The client side configuration file is left as an exercise for the reader
> > ;-).
> >
> > Thanks,
> >
> > Sam
> >
> > --
> > _______________________________
> > Sam Santiago
> > ssantiago@n0spam-SoftiTechture.com
> > http://www.SoftiTe...
> > _______________________________
> > "hazz" <hazz@sonic.net> wrote in message
> > news:%233OkC5RtEHA.4044@TK2MSFTNGP09.phx.gbl...
> > > The following code successfully turns an existing assembly into a
server
> > > object to which my client app successfully connects and invokes a
method
> > > from the server object.
> > >
> > > TcpServerChannel channel = new TcpServerChannel(8086);
> > > ChannelServices.RegisterChannel(channel);
> > >
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
> > > i",WellKnownObjectMode.SingleCall)
> > >
> > > System.Console.WriteLine("hit to exit");
> > > System.Console.ReadLine();
> > >
> > > Can I create a config file out of these few lines of code?
> > >
> > > thank you. -hazz
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>


Greg

10/18/2004 4:55:00 PM

0

Is this the magic line I need for the host application whether it be a
Windows form app, a service, a console app, et?

RemotingConfiguration.Configure("Listener.exe.config");

hazz

"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
news:uzGw2mStEHA.160@TK2MSFTNGP11.phx.gbl...
> I'm not 100% sure of what you're asking. The configuration performed by
the
> first three lines could certainly be placed in a config file, e.g.
>
> <configuration>
> <system.runtime.remoting>
> <application>
> <channels>
> <channel ref="tcp" port="8086" />
> </channels>
> <server>
> <wellknown mode="SingleCall" type="ServerClass, ServerAssembly"
> objectUri="MyUri" />
> </server>
> </application>
> </system.runtime.remoting>
> </configuration>
>
> The last two, of course, could not -- they are application code and not
> configuration. Are you asking if it's possible to use an assembly as a
> remote object without writing a host application and simply using a config
> file? If so, the answer is no, although you can achieve essentialy
something
> like this by using IIS as your host (i.e. this would mean you wouldn't
have
> to write your own host app).
>
> Ken
>
>
> "hazz" <hazz@sonic.net> wrote in message
> news:%233OkC5RtEHA.4044@TK2MSFTNGP09.phx.gbl...
> > The following code successfully turns an existing assembly into a server
> > object to which my client app successfully connects and invokes a method
> > from the server object.
> >
> > TcpServerChannel channel = new TcpServerChannel(8086);
> > ChannelServices.RegisterChannel(channel);
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
> > i",WellKnownObjectMode.SingleCall)
> >
> > System.Console.WriteLine("hit to exit");
> > System.Console.ReadLine();
> >
> > Can I create a config file out of these few lines of code?
> >
> > thank you. -hazz
> >
> >
> >
> >
> >
> >
>
>


Sam Santiago

10/18/2004 4:57:00 PM

0

In that case, check out these links:

Read the Hosts section in this document:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt11.asp?frame=true#scalenetchapt...

and check out these links:

How To: Host a Remote Object in a Windows Service
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT15.asp?...

HOW TO: Host a Remote Object in Microsoft Internet Information Services
http://support.microsoft.com/default.aspx?scid=kb;en...

Thanks,

Sam



--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"hazz" <hazz@sonic.net> wrote in message
news:emPa1GTtEHA.2192@TK2MSFTNGP14.phx.gbl...
> Actually Ken you guessed my dilemna. I was told by the "remoting resource"
> where I am working that all I have to do is add a config file to the
> existing codebase and presto, as long as I have MarshalByRefObj, then I am
> off and running.
> You are saying that I do indeed need a host application? Or host in IIS?
> Is the host application then what kickstarts the process? So the host
> application is either an .exe that one has to manually execute, or it
> becomes a service...or it is hosted in IIS in which case the client's call
> to a specific URI contained in the server's web config file launches the
> process?
> Thank you for seeing my confusion and asking the question.
> hazz
>
> "Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
> news:uzGw2mStEHA.160@TK2MSFTNGP11.phx.gbl...
> > I'm not 100% sure of what you're asking. The configuration performed by
> the
> > first three lines could certainly be placed in a config file, e.g.
> >
> > <configuration>
> > <system.runtime.remoting>
> > <application>
> > <channels>
> > <channel ref="tcp" port="8086" />
> > </channels>
> > <server>
> > <wellknown mode="SingleCall" type="ServerClass, ServerAssembly"
> > objectUri="MyUri" />
> > </server>
> > </application>
> > </system.runtime.remoting>
> > </configuration>
> >
> > The last two, of course, could not -- they are application code and not
> > configuration. Are you asking if it's possible to use an assembly as a
> > remote object without writing a host application and simply using a
config
> > file? If so, the answer is no, although you can achieve essentialy
> something
> > like this by using IIS as your host (i.e. this would mean you wouldn't
> have
> > to write your own host app).
> >
> > Ken
> >
> >
> > "hazz" <hazz@sonic.net> wrote in message
> > news:%233OkC5RtEHA.4044@TK2MSFTNGP09.phx.gbl...
> > > The following code successfully turns an existing assembly into a
server
> > > object to which my client app successfully connects and invokes a
method
> > > from the server object.
> > >
> > > TcpServerChannel channel = new TcpServerChannel(8086);
> > > ChannelServices.RegisterChannel(channel);
> > >
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
> > > i",WellKnownObjectMode.SingleCall)
> > >
> > > System.Console.WriteLine("hit to exit");
> > > System.Console.ReadLine();
> > >
> > > Can I create a config file out of these few lines of code?
> > >
> > > thank you. -hazz
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>


Ken Kolda

10/18/2004 6:24:00 PM

0

If you place your remoting configuration information in a config file, then
you must call RemotingConfiguration.Config() as you have it in order to have
that info parsed and used. The one exception is if you host your object
under IIS. In that case, the remoting information goes in your web.config
and will be automatically read when the web app is start by IIS.

Ken


"hazz" <hazz@sonic.net> wrote in message
news:%23%234hlMTtEHA.2192@TK2MSFTNGP14.phx.gbl...
> Is this the magic line I need for the host application whether it be a
> Windows form app, a service, a console app, et?
>
> RemotingConfiguration.Configure("Listener.exe.config");
>
> hazz
>
> "Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
> news:uzGw2mStEHA.160@TK2MSFTNGP11.phx.gbl...
> > I'm not 100% sure of what you're asking. The configuration performed by
> the
> > first three lines could certainly be placed in a config file, e.g.
> >
> > <configuration>
> > <system.runtime.remoting>
> > <application>
> > <channels>
> > <channel ref="tcp" port="8086" />
> > </channels>
> > <server>
> > <wellknown mode="SingleCall" type="ServerClass, ServerAssembly"
> > objectUri="MyUri" />
> > </server>
> > </application>
> > </system.runtime.remoting>
> > </configuration>
> >
> > The last two, of course, could not -- they are application code and not
> > configuration. Are you asking if it's possible to use an assembly as a
> > remote object without writing a host application and simply using a
config
> > file? If so, the answer is no, although you can achieve essentialy
> something
> > like this by using IIS as your host (i.e. this would mean you wouldn't
> have
> > to write your own host app).
> >
> > Ken
> >
> >
> > "hazz" <hazz@sonic.net> wrote in message
> > news:%233OkC5RtEHA.4044@TK2MSFTNGP09.phx.gbl...
> > > The following code successfully turns an existing assembly into a
server
> > > object to which my client app successfully connects and invokes a
method
> > > from the server object.
> > >
> > > TcpServerChannel channel = new TcpServerChannel(8086);
> > > ChannelServices.RegisterChannel(channel);
> > >
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerClass),"MyUr
> > > i",WellKnownObjectMode.SingleCall)
> > >
> > > System.Console.WriteLine("hit to exit");
> > > System.Console.ReadLine();
> > >
> > > Can I create a config file out of these few lines of code?
> > >
> > > thank you. -hazz
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>