[lnkForumImage]
TotalShareware - Download Free Software

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


 

Jean-Francois Hamelin

7/16/2004 2:23:00 PM

Hi,

I have defined an interface that is implemented by my server object, my
server object is hosted in IIS. Now I want to client activate the server
object, but the client only that the interface definition. When I do
something like:

IClass1 remoteClass1 = Activator.CreateInstance( typeof( IClass1 ) ) as
IClass1;

I received the following exception: Cannot create an instance of an
interface. Which is understandable.

Is it possible to this?

Thanks in advance.
JF


2 Answers

Allen Anderson

7/16/2004 3:01:00 PM

0

you need to create the instance of the server class type and cast it
to the interface.

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

On Fri, 16 Jul 2004 10:22:56 -0400, "Jean-Francois Hamelin"
<againstunwantedmailinglist@hotmail.com> wrote:

>Hi,
>
>I have defined an interface that is implemented by my server object, my
>server object is hosted in IIS. Now I want to client activate the server
>object, but the client only that the interface definition. When I do
>something like:
>
>IClass1 remoteClass1 = Activator.CreateInstance( typeof( IClass1 ) ) as
>IClass1;
>
>I received the following exception: Cannot create an instance of an
>interface. Which is understandable.
>
>Is it possible to this?
>
>Thanks in advance.
>JF
>

Sunny

7/16/2004 3:17:00 PM

0

What type is yoyr remoting object SAO or CAO?

If it is SAO - use Activator.GetObject

For CAO, you have to implement SAO Factory.

Take a look at Allen's article:

http://www.glacialcomponents.com/ArticleDetail.aspx?articleI...

It is about abstract class approach, but works the same way with
interfaces.

Hope that helps
Sunny


In article <ewv3wB0aEHA.3752@TK2MSFTNGP12.phx.gbl>,
againstunwantedmailinglist@hotmail.com says...
> Hi,
>
> I have defined an interface that is implemented by my server object, my
> server object is hosted in IIS. Now I want to client activate the server
> object, but the client only that the interface definition. When I do
> something like:
>
> IClass1 remoteClass1 = Activator.CreateInstance( typeof( IClass1 ) ) as
> IClass1;
>
> I received the following exception: Cannot create an instance of an
> interface. Which is understandable.
>
> Is it possible to this?
>
> Thanks in advance.
> JF
>
>
>