[MonoDevelop] Trying to Load assemblyes "on-the-fly"
Carlos Prado García
carlos.prado@hispalinux.es
Thu, 29 Apr 2004 01:53:50 +0200
--=-JeMGvg/B6+vNxEM4Ypum
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
hi,
Try this:
Assembly a =
Assembly.Load(System.IO.Path.GetFullPath("DLLImport.dll"));
Type[] types = a.GetTypes( );
foreach(Type t in types)
{
Console.WriteLine("Type is {0}", t);
}
Console.WriteLine(
"{0} types found", types.Length);
El jue, 29-04-2004 a las 00:37, +0000, Paulo Aboim Pinto escribió:
> Hello
>
> i'm trying to make a program that should load some DLL "on-the-fly" like
> plugins.
>
> I'm having the problem with, where to put the DLLs do Load. I've try in
> the root directory of the program, or even in the same directory of the
> EXE, i also try the plugin directory and i get the same error:
>
> esqueleto@hercules Debug $ ll
> total 12K
> -rwxr-xr-x 1 esqueleto wheel 4,0K Abr 29 00:10 DLLImport.dll
> -rwxr-xr-x 1 esqueleto wheel 4,5K Abr 29 00:31 LoadDLL.exe
> esqueleto@hercules Debug $ mono LoadDLL.exe
>
>
> Unhandled Exception: System.IO.FileNotFoundException: File
> 'DLLImport.dll' not found.
> in (unmanaged) /usr/lib/libmono.so.0(mono_raise_exception+0x1f) [0x400a60bf]
> in (unmanaged) /usr/lib/libmono.so.0 [0x400cd998]
> in <0x0006c> (wrapper remoting-invoke-with-check)
> System.AppDomain:LoadAssembly (string,System.Security.Policy.Evidence)
> in <0x0006b> System.AppDomain:Load (string)
> in <0x00058> (wrapper remoting-invoke-with-check) System.AppDomain:Load
> (string)in <0x0001d> System.Reflection.Assembly:Load (string)
> in <0x0002b> MainClass:Main (string[])
>
>
> esqueleto@hercules Debug $
>
>
> As you can see, i have the DLL in the same directory of the EXE, and i
> get the error that the DLL is not there .. :(
>
> this is the code that i'm using
> Assembly a = Assembly.Load("DLLImport.dll");
> Type[] types = a.GetTypes( );
> foreach(Type t in types)
> {
> Console.WriteLine("Type is {0}", t);
> }
> Console.WriteLine(
> "{0} types found", types.Length);
>
> The DLL that i'm trying to import is a test one, with and method that
> return one number.
> Anyone can help me ????
>
>
> (())
> Paulo Aboim Pinto
> From: Portugal
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-list
--=-JeMGvg/B6+vNxEM4Ypum
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.1.10">
</HEAD>
<BODY>
hi,<BR>
<BR>
Try this:<BR>
Assembly a = Assembly.Load(<B>System.IO.Path.GetFullPath(</B>"DLLImport.dll"<B>)</B>);<BR>
Type[] types = a.GetTypes( );<BR>
foreach(Type t in types)<BR>
{<BR>
Console.WriteLine("Type is {0}", t);<BR>
}<BR>
Console.WriteLine(<BR>
"{0} types found", types.Length);<BR>
<BR>
<BR>
El jue, 29-04-2004 a las 00:37, +0000, Paulo Aboim Pinto escribió:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hello</FONT>
<FONT COLOR="#000000">i'm trying to make a program that should load some DLL "on-the-fly" like </FONT>
<FONT COLOR="#000000">plugins.</FONT>
<FONT COLOR="#000000">I'm having the problem with, where to put the DLLs do Load. I've try in </FONT>
<FONT COLOR="#000000">the root directory of the program, or even in the same directory of the </FONT>
<FONT COLOR="#000000">EXE, i also try the plugin directory and i get the same error:</FONT>
<FONT COLOR="#000000">esqueleto@hercules Debug $ ll</FONT>
<FONT COLOR="#000000">total 12K</FONT>
<FONT COLOR="#000000">-rwxr-xr-x 1 esqueleto wheel 4,0K Abr 29 00:10 DLLImport.dll</FONT>
<FONT COLOR="#000000">-rwxr-xr-x 1 esqueleto wheel 4,5K Abr 29 00:31 LoadDLL.exe</FONT>
<FONT COLOR="#000000">esqueleto@hercules Debug $ mono LoadDLL.exe</FONT>
<FONT COLOR="#000000"> </FONT>
<FONT COLOR="#000000">Unhandled Exception: System.IO.FileNotFoundException: File </FONT>
<FONT COLOR="#000000">'DLLImport.dll' not found.</FONT>
<FONT COLOR="#000000">in (unmanaged) /usr/lib/libmono.so.0(mono_raise_exception+0x1f) [0x400a60bf]</FONT>
<FONT COLOR="#000000">in (unmanaged) /usr/lib/libmono.so.0 [0x400cd998]</FONT>
<FONT COLOR="#000000">in <0x0006c> (wrapper remoting-invoke-with-check) </FONT>
<FONT COLOR="#000000">System.AppDomain:LoadAssembly (string,System.Security.Policy.Evidence)</FONT>
<FONT COLOR="#000000">in <0x0006b> System.AppDomain:Load (string)</FONT>
<FONT COLOR="#000000">in <0x00058> (wrapper remoting-invoke-with-check) System.AppDomain:Load </FONT>
<FONT COLOR="#000000">(string)in <0x0001d> System.Reflection.Assembly:Load (string)</FONT>
<FONT COLOR="#000000">in <0x0002b> MainClass:Main (string[])</FONT>
<FONT COLOR="#000000"> </FONT>
<FONT COLOR="#000000">esqueleto@hercules Debug $</FONT>
<FONT COLOR="#000000">As you can see, i have the DLL in the same directory of the EXE, and i </FONT>
<FONT COLOR="#000000">get the error that the DLL is not there .. :(</FONT>
<FONT COLOR="#000000">this is the code that i'm using </FONT>
<FONT COLOR="#000000"> Assembly a = Assembly.Load("DLLImport.dll");</FONT>
<FONT COLOR="#000000"> Type[] types = a.GetTypes( );</FONT>
<FONT COLOR="#000000"> foreach(Type t in types)</FONT>
<FONT COLOR="#000000"> {</FONT>
<FONT COLOR="#000000"> Console.WriteLine("Type is {0}", t);</FONT>
<FONT COLOR="#000000"> }</FONT>
<FONT COLOR="#000000"> Console.WriteLine(</FONT>
<FONT COLOR="#000000"> "{0} types found", types.Length);</FONT>
<FONT COLOR="#000000">The DLL that i'm trying to import is a test one, with and method that </FONT>
<FONT COLOR="#000000">return one number.</FONT>
<FONT COLOR="#000000">Anyone can help me ????</FONT>
<FONT COLOR="#000000">(())</FONT>
<FONT COLOR="#000000">Paulo Aboim Pinto</FONT>
<FONT COLOR="#000000">From: Portugal</FONT>
<FONT COLOR="#000000">_______________________________________________</FONT>
<FONT COLOR="#000000">Monodevelop-list mailing list</FONT>
<A HREF="mailto:Monodevelop-list@lists.ximian.com">Monodevelop-list@lists.ximian.com</A>
<A HREF="http://lists.ximian.com/mailman/listinfo/monodevelop-list">http://lists.ximian.com/mailman/listinfo/monodevelop-list</A>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-JeMGvg/B6+vNxEM4Ypum--