Load an Assembly from a Remote Location

Problem

You want to run an assembly from a server on your local network or the Internet.

Solution

Use the Assembly.LoadFrom method with a Uniform Resource Identifier (URI) that points to the remote assembly.

Discussion

The Assembly.LoadFrom method accepts an ordinary file path, a network universal naming convention (UNC) path, or a URL Web path. LoadFrom is sometimes used with highly dynamic applications that load components from the Web.

Here’s a basic example that loads an assembly using a URI:

Dim Asm As System.Reflection.Assembly
Dim AsmPath As String = "http://myserver/mydir/myassembly.dll"
Asm = System.Reflection.Assembly.LoadFrom(AsmPath)

If you call LoadFrom and supply a path to a remote assembly, that assembly ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.