[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

Need Help to Understand Creating a Client Access to Remote Object?

Linno Hak

7/11/2004 5:46:00 AM

Hi,

I'm new to .Net remoting. Hope someone can help to clarify my understanding
regarding creating a client access to a Remote Server object. I've read a
number of
articles on .Net Remoting and I think I understand the principles of how to
design a .Net remoting app. I understand that there are 3 ways for a client
to reference remote objects:

A. Add Reference to the Server object (dll or exe) when both the client and
server components are at the same development site.
B. Derive the Server object from an interface class when the client and
server components are NOT at the same development site.
C. Use SOAPSUDS tool to extract the required metadata from a running Server
object. This is useful when client and server components are developed
at different sites.

I am not sure whether I understand Options B and C correctly or know how to
do options B and C. However my question are:

1. If the Remote Object that my Client app(ASP.Net) wants to
call/instantiate is NOT located on a the same computer that I'm developing
my Client app ,
do I need to map a logical drive to the Computer where the Remote
Object is and then from my Client app I add a reference to the Remote Object
by
browsing the dll or exe on the mapped drive or copy the dll/exe to the
\bin folder of my Client app?.

This is where I'm a bit confused. If the source code/implementation
details of the Remote Object need to be physically located on the Client
machine, how is
.Net Remoting working?. I mean isn't the purpose of .Net Remoting is
where you host one Remote Object on a central Server/Computer where clients
can
instantiate?. Hope my question is clear.

2. I've create a small .Net Remoting application using WebServices to
host one Remote Object and an ASP.Net client. I use Global.asax
(Application_Start)
and Web.config of the ASP.Net client to tell it to use the remote
object. I also use Global.asax of the WebServices to register the remote
object with the
remoting system. When I test the ASP.Net to add a few records to the
SQL database, it works as expected.

Since all my projects are in one solution and on the same computer,
my question is how do I know that my ASP.Net client is actually using the
Remote
Object hosted by the WebServices?. I also tried to use the ASP.net
client from a different computer but had to copy the dll of the remote
object to this other
computer so I can use its properties and methods. I can remotely add
records to the database successfully even when I disable the remoting
configurations
in Web.config file of the ASP.Net client. Because of this I don't
think my .Net Remoting is not working. I'm confused!.

Hope you can understand my questions.


4 Answers

Allen Anderson

7/12/2004 6:20:00 PM

0

check out this article I wrote to help beginners get working code up
and running.

http://www.glacialcomp.../ArticleDetail.aspx?articleID=Re...

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

On Sun, 11 Jul 2004 15:46:07 +1000, "Linno Hak"
<hak1lin@police.nsw.gov.au> wrote:

>Hi,
>
>I''m new to .Net remoting. Hope someone can help to clarify my understanding
>regarding creating a client access to a Remote Server object. I''ve read a
>number of
>articles on .Net Remoting and I think I understand the principles of how to
>design a .Net remoting app. I understand that there are 3 ways for a client
>to reference remote objects:
>
>A. Add Reference to the Server object (dll or exe) when both the client and
>server components are at the same development site.
>B. Derive the Server object from an interface class when the client and
>server components are NOT at the same development site.
>C. Use SOAPSUDS tool to extract the required metadata from a running Server
>object. This is useful when client and server components are developed
> at different sites.
>
>I am not sure whether I understand Options B and C correctly or know how to
>do options B and C. However my question are:
>
>1. If the Remote Object that my Client app(ASP.Net) wants to
>call/instantiate is NOT located on a the same computer that I''m developing
>my Client app ,
> do I need to map a logical drive to the Computer where the Remote
>Object is and then from my Client app I add a reference to the Remote Object
>by
> browsing the dll or exe on the mapped drive or copy the dll/exe to the
>\bin folder of my Client app?.
>
> This is where I''m a bit confused. If the source code/implementation
>details of the Remote Object need to be physically located on the Client
>machine, how is
> .Net Remoting working?. I mean isn''t the purpose of .Net Remoting is
>where you host one Remote Object on a central Server/Computer where clients
>can
> instantiate?. Hope my question is clear.
>
>2. I''ve create a small .Net Remoting application using WebServices to
>host one Remote Object and an ASP.Net client. I use Global.asax
>(Application_Start)
> and Web.config of the ASP.Net client to tell it to use the remote
>object. I also use Global.asax of the WebServices to register the remote
>object with the
> remoting system. When I test the ASP.Net to add a few records to the
>SQL database, it works as expected.
>
> Since all my projects are in one solution and on the same computer,
>my question is how do I know that my ASP.Net client is actually using the
>Remote
> Object hosted by the WebServices?. I also tried to use the ASP.net
>client from a different computer but had to copy the dll of the remote
>object to this other
> computer so I can use its properties and methods. I can remotely add
>records to the database successfully even when I disable the remoting
>configurations
> in Web.config file of the ASP.Net client. Because of this I don''t
>think my .Net Remoting is not working. I''m confused!.
>
>Hope you can understand my questions.
>

Sunny

7/12/2004 6:56:00 PM

0

Hi Linno,

please read inline:


In article <up0qNswZEHA.2340@TK2MSFTNGP09.phx.gbl>,
hak1lin@police.nsw.gov.au says...
> Hi,
>
> I''m new to .Net remoting. Hope someone can help to clarify my understanding
> regarding creating a client access to a Remote Server object. I''ve read a
> number of
> articles on .Net Remoting and I think I understand the principles of how to
> design a .Net remoting app. I understand that there are 3 ways for a client
> to reference remote objects:
>
> A. Add Reference to the Server object (dll or exe) when both the client and
> server components are at the same development site.
> B. Derive the Server object from an interface class when the client and
> server components are NOT at the same development site.
> C. Use SOAPSUDS tool to extract the required metadata from a running Server
> object. This is useful when client and server components are developed
> at different sites.

This is not completely correct. The main idea is that the client have to
know what kind of object and what methods it can call. How you can call
something without knowing what. The web services has their WSDL
mechanism so the client can connect, get the method info and create a
proxy (what VS.Net is doing when you add web reference).
While web services have been designed to be very interoperatable, and
they allow such a loosely coupling, remoting was designed to allow (as
main) cross-app-domain object instaniation, which includes cross-process
and cross-machine (as the last two are using different appdomains as
well).

So back to the main point. With remoting, the client have to know
exactly the type of the object (or its interfaces). And because in .Net
every type is defined by the following attributes - name, namespace and
assembly, the client have to have access to the same assembly, from
which the server has created the object (and in the case of SOAPSUDS
client has access to a metadata copy of that assembly, without the code
of the object).

It has nothing to do with what is your development machine, etc. Just
the client program and the server program have to have access to the
same assembly (dll) in which the remoting object is created.

That defines the 3 options you have:

1. Copy and reference the implementation dll both from the server and
the client (not recommended, as it is very easy to disassemble the code,
shipped with the client).
2. Use SOAPSUDS. There are some problems with soapsuds, which may be
corrected with SP1 or in v.2 of the framework, but still this is not my
preferred (you can read some discussions in this group about the topic).
3. Use interface (or abstract base class) library, so you do not ship
the main code. Allen Anderson has very good article about base class
approach (it is his favorite approach). I''m planning to create one on
the interfaces, but can not find time. The link to Allen''s article is
(watch out for line wraps):
http://www.glacialcomponents.com/ArticleDe...
articleID=RemoteObject


>
> I am not sure whether I understand Options B and C correctly or know how to
> do options B and C. However my question are:
>
> 1. If the Remote Object that my Client app(ASP.Net) wants to
> call/instantiate is NOT located on a the same computer that I''m developing
> my Client app ,
> do I need to map a logical drive to the Computer where the Remote
> Object is and then from my Client app I add a reference to the Remote Object
> by
> browsing the dll or exe on the mapped drive or copy the dll/exe to the
> \bin folder of my Client app?.
>
> This is where I''m a bit confused. If the source code/implementation
> details of the Remote Object need to be physically located on the Client
> machine, how is
> .Net Remoting working?. I mean isn''t the purpose of .Net Remoting is
> where you host one Remote Object on a central Server/Computer where clients
> can
> instantiate?. Hope my question is clear.
>
> 2. I''ve create a small .Net Remoting application using WebServices to
> host one Remote Object and an ASP.Net client. I use Global.asax
> (Application_Start)
> and Web.config of the ASP.Net client to tell it to use the remote
> object. I also use Global.asax of the WebServices to register the remote
> object with the
> remoting system. When I test the ASP.Net to add a few records to the
> SQL database, it works as expected.
>
> Since all my projects are in one solution and on the same computer,
> my question is how do I know that my ASP.Net client is actually using the
> Remote
> Object hosted by the WebServices?. I also tried to use the ASP.net
> client from a different computer but had to copy the dll of the remote
> object to this other
> computer so I can use its properties and methods. I can remotely add
> records to the database successfully even when I disable the remoting
> configurations
> in Web.config file of the ASP.Net client. Because of this I don''t
> think my .Net Remoting is not working. I''m confused!.

This is one of the problems with using config files to setup the
remoting. If something is wrong, the client instaniates a local object
(if the object dll is shipped with the client, or they are on the same
machine). There is another (not officially confirmed) problem with a
memory leak. Thats why I prefer not to use config files and the code
assembly. If you use abstract class or interfaces, the client has no
access to the object code, so it can not instaniate the object and you
will know that the config is wrong somewhere.

>
> Hope you can understand my questions.
>

Hope you can understand my explanations :)

Cheers
Sunny

lhak

7/14/2004 9:38:00 AM

0

Thanks heaps Sunny. I understand better now.

Linno


"Sunny" <sunny@newsgroups.nospam> wrote in message
news:utkzjHEaEHA.2844@TK2MSFTNGP12.phx.gbl...
> Hi Linno,
>
> please read inline:
>
>
> In article <up0qNswZEHA.2340@TK2MSFTNGP09.phx.gbl>,
> hak1lin@police.nsw.gov.au says...
> > Hi,
> >
> > I''m new to .Net remoting. Hope someone can help to clarify my
understanding
> > regarding creating a client access to a Remote Server object. I''ve read
a
> > number of
> > articles on .Net Remoting and I think I understand the principles of how
to
> > design a .Net remoting app. I understand that there are 3 ways for a
client
> > to reference remote objects:
> >
> > A. Add Reference to the Server object (dll or exe) when both the client
and
> > server components are at the same development site.
> > B. Derive the Server object from an interface class when the client and
> > server components are NOT at the same development site.
> > C. Use SOAPSUDS tool to extract the required metadata from a running
Server
> > object. This is useful when client and server components are developed
> > at different sites.
>
> This is not completely correct. The main idea is that the client have to
> know what kind of object and what methods it can call. How you can call
> something without knowing what. The web services has their WSDL
> mechanism so the client can connect, get the method info and create a
> proxy (what VS.Net is doing when you add web reference).
> While web services have been designed to be very interoperatable, and
> they allow such a loosely coupling, remoting was designed to allow (as
> main) cross-app-domain object instaniation, which includes cross-process
> and cross-machine (as the last two are using different appdomains as
> well).
>
> So back to the main point. With remoting, the client have to know
> exactly the type of the object (or its interfaces). And because in .Net
> every type is defined by the following attributes - name, namespace and
> assembly, the client have to have access to the same assembly, from
> which the server has created the object (and in the case of SOAPSUDS
> client has access to a metadata copy of that assembly, without the code
> of the object).
>
> It has nothing to do with what is your development machine, etc. Just
> the client program and the server program have to have access to the
> same assembly (dll) in which the remoting object is created.
>
> That defines the 3 options you have:
>
> 1. Copy and reference the implementation dll both from the server and
> the client (not recommended, as it is very easy to disassemble the code,
> shipped with the client).
> 2. Use SOAPSUDS. There are some problems with soapsuds, which may be
> corrected with SP1 or in v.2 of the framework, but still this is not my
> preferred (you can read some discussions in this group about the topic).
> 3. Use interface (or abstract base class) library, so you do not ship
> the main code. Allen Anderson has very good article about base class
> approach (it is his favorite approach). I''m planning to create one on
> the interfaces, but can not find time. The link to Allen''s article is
> (watch out for line wraps):
> http://www.glacialcomponents.com/ArticleDe...
> articleID=RemoteObject
>
>
> >
> > I am not sure whether I understand Options B and C correctly or know how
to
> > do options B and C. However my question are:
> >
> > 1. If the Remote Object that my Client app(ASP.Net) wants to
> > call/instantiate is NOT located on a the same computer that I''m
developing
> > my Client app ,
> > do I need to map a logical drive to the Computer where the Remote
> > Object is and then from my Client app I add a reference to the Remote
Object
> > by
> > browsing the dll or exe on the mapped drive or copy the dll/exe to
the
> > \bin folder of my Client app?.
> >
> > This is where I''m a bit confused. If the source
code/implementation
> > details of the Remote Object need to be physically located on the Client
> > machine, how is
> > .Net Remoting working?. I mean isn''t the purpose of .Net Remoting
is
> > where you host one Remote Object on a central Server/Computer where
clients
> > can
> > instantiate?. Hope my question is clear.
> >
> > 2. I''ve create a small .Net Remoting application using WebServices to
> > host one Remote Object and an ASP.Net client. I use Global.asax
> > (Application_Start)
> > and Web.config of the ASP.Net client to tell it to use the remote
> > object. I also use Global.asax of the WebServices to register the remote
> > object with the
> > remoting system. When I test the ASP.Net to add a few records to
the
> > SQL database, it works as expected.
> >
> > Since all my projects are in one solution and on the same
computer,
> > my question is how do I know that my ASP.Net client is actually using
the
> > Remote
> > Object hosted by the WebServices?. I also tried to use the
ASP.net
> > client from a different computer but had to copy the dll of the remote
> > object to this other
> > computer so I can use its properties and methods. I can remotely
add
> > records to the database successfully even when I disable the remoting
> > configurations
> > in Web.config file of the ASP.Net client. Because of this I don''t
> > think my .Net Remoting is not working. I''m confused!.
>
> This is one of the problems with using config files to setup the
> remoting. If something is wrong, the client instaniates a local object
> (if the object dll is shipped with the client, or they are on the same
> machine). There is another (not officially confirmed) problem with a
> memory leak. Thats why I prefer not to use config files and the code
> assembly. If you use abstract class or interfaces, the client has no
> access to the object code, so it can not instaniate the object and you
> will know that the config is wrong somewhere.
>
> >
> > Hope you can understand my questions.
> >
>
> Hope you can understand my explanations :)
>
> Cheers
> Sunny


lhak

7/14/2004 9:41:00 AM

0

Thank you Allen for the very useful reference and also easy to follow.
Linno
"Allen Anderson" <allen@sparkysystems.com> wrote in message
news:7hl5f0hv29fbvgs24ib7c78ukhib5n7s98@4ax.com...
> check out this article I wrote to help beginners get working code up
> and running.
>
> http://www.glacialcomp.../ArticleDetail.aspx?articleID=Re...
>
> Cheers,
> Allen Anderson
> http://www.glacialcomp...
> mailto: allen@put my website base here.com
>
> On Sun, 11 Jul 2004 15:46:07 +1000, "Linno Hak"
> <hak1lin@police.nsw.gov.au> wrote:
>
> >Hi,
> >
> >I''m new to .Net remoting. Hope someone can help to clarify my
understanding
> >regarding creating a client access to a Remote Server object. I''ve read a
> >number of
> >articles on .Net Remoting and I think I understand the principles of how
to
> >design a .Net remoting app. I understand that there are 3 ways for a
client
> >to reference remote objects:
> >
> >A. Add Reference to the Server object (dll or exe) when both the client
and
> >server components are at the same development site.
> >B. Derive the Server object from an interface class when the client and
> >server components are NOT at the same development site.
> >C. Use SOAPSUDS tool to extract the required metadata from a running
Server
> >object. This is useful when client and server components are developed
> > at different sites.
> >
> >I am not sure whether I understand Options B and C correctly or know how
to
> >do options B and C. However my question are:
> >
> >1. If the Remote Object that my Client app(ASP.Net) wants to
> >call/instantiate is NOT located on a the same computer that I''m
developing
> >my Client app ,
> > do I need to map a logical drive to the Computer where the Remote
> >Object is and then from my Client app I add a reference to the Remote
Object
> >by
> > browsing the dll or exe on the mapped drive or copy the dll/exe to
the
> >\bin folder of my Client app?.
> >
> > This is where I''m a bit confused. If the source code/implementation
> >details of the Remote Object need to be physically located on the Client
> >machine, how is
> > .Net Remoting working?. I mean isn''t the purpose of .Net Remoting
is
> >where you host one Remote Object on a central Server/Computer where
clients
> >can
> > instantiate?. Hope my question is clear.
> >
> >2. I''ve create a small .Net Remoting application using WebServices to
> >host one Remote Object and an ASP.Net client. I use Global.asax
> >(Application_Start)
> > and Web.config of the ASP.Net client to tell it to use the remote
> >object. I also use Global.asax of the WebServices to register the remote
> >object with the
> > remoting system. When I test the ASP.Net to add a few records to
the
> >SQL database, it works as expected.
> >
> > Since all my projects are in one solution and on the same
computer,
> >my question is how do I know that my ASP.Net client is actually using the
> >Remote
> > Object hosted by the WebServices?. I also tried to use the ASP.net
> >client from a different computer but had to copy the dll of the remote
> >object to this other
> > computer so I can use its properties and methods. I can remotely
add
> >records to the database successfully even when I disable the remoting
> >configurations
> > in Web.config file of the ASP.Net client. Because of this I don''t
> >think my .Net Remoting is not working. I''m confused!.
> >
> >Hope you can understand my questions.
> >
>