I checked my project and find out the missing reference. It was even worse,
"Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
news:uB2TRGMfEHA.2468@TK2MSFTNGP12.phx.gbl...
> I would suspect that the reason is a missing referenced assembly -
something
> that is referenced by your plugin assembly is not loaded yet. Try loading
> such an assembly explicitly.
>
> By the way, a better way to do this :
> definedType.Name.Substring(0, 7).CompareTo("Module_")
> is this:
> definedType.Name.StartsWith("Module_")
> String.StartsWith method is often overlooked.
>
> I've put together a sample that loads plugins and invokes them. Pehaps it
> would be of some use to you.
>
http://www.alexfeinman.com/download.asp?doc=PluginApp.zip >
>
> --
> Alex Feinman
> ---
> Visit
http://www.opennetcf.org > "FBU" <f.debuisseret@brutele.be> wrote in message
> news:cf387u$494$1@news.brutele.be...
> > Hi,
> >
> > I'm writing a C# application for my pocket pc in which i would like to
> load
> > dynamically dll (kind of plugins).
> > In the following piece of code, the load of the assembly (.dll) works
> > perfectly and my 'assembly' variable seems to be properly initialized.
> But,
> > once i call the function GetTypes(), an exception (TypeLoadException) is
> > thrown.
> > I don't find any good reasons why i get this exception...
> >
> > Any help would be very much appreciated.
> >
> > Thank you!
> >
> > Frédéric de Buisseret.
> > public static object GetModuleFromDevice(ArrayList modules)
> > {
> > string path =
> >
>
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetN
> > ame().CodeBase);
> > path += @"\modules";
> >
> > string[] files = Directory.GetFiles(path, "Module*.dll");
> > Assembly assembly;
> >
> > foreach (string file in files) {
> > assembly = Assembly.LoadFrom(file);
> > if (assembly == null)
> > continue;
> >
> > object module = null;
> > try{
> > // look in assembly types for our class
> > Type[] types = assembly.GetTypes(); // Exception
> > here
> >
> > foreach (Type definedType in types) {
> > if (!definedType.IsClass)
> > continue;
> >
> > if (definedType.Name.Substring(0,
7).CompareTo("Module_")
> ==
> > 0) {
> > module = Activator.CreateInstance(definedType);
> > break;
> > }
> > }
> > }
> > catch (Exception e) {
> > ...
> > }
> >
> > .....
> >
> >
>
>