Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Assembly Class
Assembly Methods
LoadFile Method
 LoadFile Method (String)

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Assembly..::.LoadFile Method (String)

Loads the contents of an assembly file on the specified path.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
Public Shared Function LoadFile ( _
    path As String _
) As Assembly
Visual Basic (Usage)
Dim path As String
Dim returnValue As [Assembly]

returnValue = Assembly.LoadFile(path)
C#
public static Assembly LoadFile(
    string path
)
Visual C++
public:
static Assembly^ LoadFile(
    String^ path
)
JScript
public static function LoadFile(
    path : String
) : Assembly

Parameters

path
Type: System..::.String
The path of the file to load.

Return Value

Type: System.Reflection..::.Assembly
The loaded assembly.
ExceptionCondition
ArgumentNullException

The path parameter is nullNothingnullptra null reference (Nothing in Visual Basic).

FileLoadException

A file that was found could not be loaded.

FileNotFoundException

The path parameter is an empty string ("") or does not exist.

BadImageFormatException

path is not a valid assembly.

-or-

Version 2.0 or later of the common language runtime is currently loaded and path was compiled with a later version.

Use the LoadFile method to load and examine assemblies that have the same identity, but are located in different paths. LoadFile does not load files into the LoadFrom context, and does not resolve dependencies using the load path, as the LoadFrom method does. LoadFile is useful in this limited scenario because LoadFrom cannot be used to load assemblies that have the same identities but different paths; it will load only the first such assembly.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Absolute path needed      KooKiz   |   Edit   |   Show History
Note that the path provided to the function needs to be absolute. You can use System.IO.Path.GetFullPath(yourPath) if you only have a relative one.
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker