[Mono-list] Casting and Plugin Issue

Rodolfo Campero rodolfocampero@hotmail.com
Mon, 28 Jun 2004 00:23:40 -0300


El lun, 28-06-2004 a las 00:02, Marcus escribi=F3:
> I think that you need to put IPlugin in the shared assembly (that the mai=
n=20
> program and plugins both references).
>=20
Yes, I agree.

> On Sunday 27 June 2004 9:19 pm, Pablo Fischer wrote:
> > Hi!
> >
> > > I don't have any other idea, but I thought that maybe instead of doin=
g:
> > >
> > > <snip>
> > > my_method =3D t.GetMethod("MGetPosts");
> > > object retVal =3D my_method.Invoke(activator,
> > >                                 BindingFlags.Instance |
> > > 				BindingFlags.NonPublic |
> > > 				BindingFlags.InvokeMethod,
> > >                                 null,
> > >                                 new Object[]{3, user},
> > >                                 null);
> > > </snip>
> > >
> > > You could do:
> > >
> > > 	IPluging p =3D (IPlugin)t;
> > > 	object retVal =3D p.MGetPosts(3, user);
> >
> > Sounds great, I tried what you said with two assemblies: one is the
> > Structs.dll (*Struct.cs) and the other Plugin.dll (Plugin.cs and the
> > interface IPlugin.cs), then I compiled MyApp with
> >
> > mcs MyApp.cs -r Structs.dll
> >
> > And then tried to cast it, and it fails:
> >
> > Test7.cs(20) error CS0246: Cannot find type `IPlugin'
> >
> > Also I did a Console.WriteLine to 't' (Type) and prints
> > MBloggy.Plugins.IPlugin.
> >
> > Seems that I can't cast an interface, or what I'm doing wrong?.
> >
> >  Assembly a;
> >  Type t;
> >  MethodInfo my_method;
> >
> >  a =3D Assembly.LoadFrom("BloggerPlugin.dll");
> >  t =3D a.GetType("MBloggy.Plugins.IPlugin");
> >  Console.WriteLine(t);
> >
> > As I said, I'm testing what you suggested, but with Reflections the
> > plugins are working great!

My wrong. I thought that t was an object instance.

> >
> > Thanks
> > Pablo
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
--=20
Rodolfo Campero
http://expertcoder.sourceforge.net/