Type System.Reflection.Assembly ad , where ad is the name of the variable to hold a reference to the assembly you're going to load.
Type an equal sign = .
Type System.Reflection.Assembly.LoadFrom ( .
Type the path to the DLL either in the traditional fashion ("c:\path\file.dll") or in URL form (with file:// or http://).
Type a close parenthesis, followed by a semicolon ( Figure 12.11 ).
Figure 12.11 LoadFrom uses the path to the assembly rather than the display string. You can use a URL to a local resource, to a network resource, or even to a Web site.
//using System.Reflection; Assembly ad = Assembly. LoadFrom ( @"file://C:/csharpvqs/ordersXML.DLL");
Tips
The LoadFrom mechanism isn't recommended for loading DLLs that are in the GAC. Instead, for DLLs in the GAC use the Load mechanism. However, if you need to download a DLL from a server in your network or from a Web site, LoadFrom is the preferred method.
You can specify a relative path with LoadFrom, but Web applications have problems with this approach, as I mentioned in an earlier tip. The problem is that they run from inside ASPNET_WP.EXE, which lives in the Windows\System32 directory. To find a file using a relative path, you first have to get the path to your application directory using the Server.MapPath function ( Figure 12.12 ).
Figure 12.12 You can't really use relative paths with LoadFrom because they end up being mapped to Windows\System32 rather than your application directory. MapPath lets you get full paths based on your application directory.