Alternative to abstract classes w/ remoting.

  • Thread starter Thread starter f00sion
  • Start date Start date
F

f00sion

I found a good tutorial of how to supply the objects without having
the implementation files on the client. This was working great until I
realized that I couldnt use any constructors with server activated
objects, so I switched to client activated objects only to run into
the next roadblock, doh! can't instantiate abstract classes... here is
a simple example of the structure, im sure there is a way to do it to
allow instantiation but I am not as knowledgeable of inheritance as I
should be:


namespace JLClient

{

public abstract class address : MarshalByRefObject

{

public abstract string foo{get;set;}

public abstract string test();

}

}



namespace JLBase

{

public class address : JLClient.address

{

public override string foo{get{return _foo;}set{_foo=value}}

public override string test()

{ return "blah"; }

private string _foo;

}

}


The client will only need to have the JLClient.dll for the structure
information and everything would work great... how do I do it without
using abstract classes and still having access to various
constructors?.
 
Hi,

I am not sure if I understood the problem correctly. Please let me know if
I am wrong.

In the example you provide an interface definition will serve this purpose
better than abstract class.
I don't hink that it will be easy to operate an object created remotely
without reffering to any type. This possibility exists - there is late
binding technology in .Net. In C# you can use it via reflection API, in
Visual Basic the language can wrap everything for you.
You can access different constructors of a type without any type
information on the client via Activator.CreateInstance method. One of the
overloads take method name and the class name as strings. So, your client
part may really have no references to the type being created.
There is actually one restriction on the constructors: constructor
arguments should not have parameters passed by reference. If a class has
such constructor and you need tto call it, it makes sense to introduce
helper class that will play a role of object factory.

Hope this helps.

--
Victor Urnyshev [MSFT]
This post is "AS IS" with no warranties, and confers no rights.
--------------------
|From: (e-mail address removed) (f00sion)
|Newsgroups: microsoft.public.dotnet.general
|Subject: Alternative to abstract classes w/ remoting.
|Date: 25 Aug 2004 09:14:55 -0700
|Organization: http://groups.google.com
|Lines: 53
|Message-ID: <[email protected]>
|NNTP-Posting-Host: 67.129.150.10
|Content-Type: text/plain; charset=ISO-8859-1
|Content-Transfer-Encoding: 8bit
|X-Trace: posting.google.com 1093450496 24481 127.0.0.1 (25 Aug 2004
16:14:56 GMT)
|X-Complaints-To: (e-mail address removed)
|NNTP-Posting-Date: Wed, 25 Aug 2004 16:14:56 +0000 (UTC)
|Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.s
ul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!p
ostnews2.google.com!not-for-mail
|Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:143599
|X-Tomcat-NG: microsoft.public.dotnet.general
|
|I found a good tutorial of how to supply the objects without having
|the implementation files on the client. This was working great until I
|realized that I couldnt use any constructors with server activated
|objects, so I switched to client activated objects only to run into
|the next roadblock, doh! can't instantiate abstract classes... here is
|a simple example of the structure, im sure there is a way to do it to
|allow instantiation but I am not as knowledgeable of inheritance as I
|should be:
|
|
|namespace JLClient
|
|{
|
|public abstract class address : MarshalByRefObject
|
|{
|
|public abstract string foo{get;set;}
|
|public abstract string test();
|
|}
|
|}
|
|
|
|namespace JLBase
|
|{
|
|public class address : JLClient.address
|
|{
|
|public override string foo{get{return _foo;}set{_foo=value}}
|
|public override string test()
|
|{ return "blah"; }
|
|private string _foo;
|
|}
|
|}
|
|
|The client will only need to have the JLClient.dll for the structure
|information and everything would work great... how do I do it without
|using abstract classes and still having access to various
|constructors?.
|
 
Back
Top