Re: modular application

From: Sami Vaaraniemi (samivawantsnospam_at_jippii.fi)
Date: 02/08/04


Date: Sun, 8 Feb 2004 09:48:53 -0700


"Saso Zagoranski" <saso.zagoranski@guest.arnes.si> wrote in message
news:c010dj$o5k$1@planja.arnes.si...
> Thanks Sami!
> You really helped me a lot!
>
> Just one more thing :)
> How do you "cast" an object if you have the Type of the object stored in
> some variable t?
> So you can't use:
> myGpsObject = (Gps) myObject;
>
> but instead:
> myGpsObject = ??? t.GetType() ???

You cannot get an instance out of a type simply by casting. When you cast,
you always cast a reference to an instance, like so:

    object obj = new SomeClass();
    // Now cast 'obj' to a reference to 'SomeClass'
    SomeClass sc = (SomeClass)obj;

Btw, there are a number of articles on the net that show how to create a
pluggable architecture. I know there is one on www.codeproject.com (I can't
seem to access it now). There's another one written in VB.NET on
developerfusion.com: http://www.developerfusion.com/show/4371/ .

I also wrote a quick C# sample that shows one way of doing a pluggable
architecture. It is very similar to the articles above. My sample is
available for download at http://www.capehill.net/pluginsample.zip . I might
add some security specific stuff to this sample later if I have the time...

Sami