3.1. Load an Assembly into the Current Application Domain

Problem

You need to load an assembly into the current application domain at runtime.

Solution

Use the Shared Load method or the LoadFrom method of the System.Reflection.Assembly class.

NOTE

The Assembly.LoadWithPartialName method has been deprecated in .NET Framework 2.0. Instead, you should use the Assembly.Load method described in this recipe.

How It Works

Unlike with Win32, where the referenced DLLs are loaded when the process starts, the common language runtime (CLR) will automatically load the assemblies referenced by your assembly only when the metadata for their contained types is required. However, you can also explicitly instruct the runtime to load assemblies. The Load and ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach 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.