FileLoadException 类

定义

找到托管程序集但不能加载时引发的异常。The exception that is thrown when a managed assembly is found but cannot be loaded.

public ref class FileLoadException : System::IO::IOException
public class FileLoadException : System.IO.IOException
[System.Serializable]
public class FileLoadException : System.IO.IOException
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class FileLoadException : System.IO.IOException
type FileLoadException = class
    inherit IOException
Public Class FileLoadException
Inherits IOException
继承
FileLoadException
继承
属性

注解

表示当找不到 Assembly 文件时出现的错误。Represents the error that occurs when a Assembly file is found but cannot be loaded.

如果文件无法加载,则会引发 FileNotFoundException 异常,因为找不到该文件。The FileNotFoundException exception is thrown when the file fails to load because it cannot be located. 如果文件已找到,但由于权限不足而无法加载,则会引发 SecurityExceptionIf the file is located, but cannot be loaded due to insufficient permissions, a SecurityException is thrown.

FileLoadException 具有 COR_E_FILELOAD 的默认 HRESULT,该默认值为0x80131621,但这不是唯一可能的 HRESULT。FileLoadException has the default HRESULT of COR_E_FILELOAD, which has the value 0x80131621, but this is not the only possible HRESULT.

如果你的代码没有 PathDiscovery 的权限,则此异常的错误消息可能只包含文件或目录名称,而不是完全限定的路径。If your code does not have PathDiscovery permission, the error message for this exception may only contain file or directory names instead of fully qualified paths.

备注

Windows 应用商店应用可移植类库中未包含此异常,但它由某些成员引发。This exception is not included in the .NET for Windows Store apps or the Portable Class Library, but it is thrown by some members that are. 若要在这种情况下捕获异常,请改为写入 IOExceptioncatch 语句。To catch the exception in that case, write a catch statement for IOException instead.

相关提示Associated Tips

请确保该文件是有效的 .NET Framework 程序集。Make sure that the file is a valid .NET Framework assembly.
如果文件不是有效的 .NET Framework 程序集,则会引发此异常。This exception is thrown if the file is not a valid .NET Framework assembly. 有关详细信息,请参阅 AssemblyFor more information, see Assembly.

检查以确保未使用两个不同的证据加载两次程序集或模块。Check to make sure an assembly or module was not loaded twice with two different evidences.
证据是输入安全策略决策的一组信息(如代码可授予哪些权限)。Evidence is the set of information that constitutes input to security policy decisions, such as what permissions can be granted to code. 有关详细信息,请参见GacRemoveEvidenceFor more information, see GacRemove and Evidence

如果使用 RegisterAssemblyUnRegisterAssembly 方法,请检查以确保程序集名称的长度不超过系统定义的最大长度。If using the RegisterAssembly or UnRegisterAssembly methods, check to make sure the assembly name is not longer than the system-defined maximum length.
程序集名称的长度不能超过系统定义的最大值。The assembly name's length cannot exceed the system-defined maximum. 有关详细信息,请参阅 PathTooLongExceptionFor more information, see PathTooLongException.

如果加载附属程序集,请确保指定的 CultureInfo 与文件的 CultureInfo 匹配。If loading a satellite assembly, make sure the specified CultureInfo matches the file's CultureInfo.
附属程序集包含本地化资源,这些资源包含单个区域性(用作默认或非特定区域性)的非本地化可执行代码和资源。Satellite assemblies contain localized resources which contain non-localizable executable code and resources for a single culture that serve as the default or neutral culture. 有关详细信息,请参阅 GetSatelliteAssemblyFor more information, see GetSatelliteAssembly.

构造函数

FileLoadException()

初始化 FileLoadException 类的新实例,将新实例的 Message 属性设置为描述错误的系统提供的消息(如“无法加载指定文件”)。Initializes a new instance of the FileLoadException class, setting the Message property of the new instance to a system-supplied message that describes the error, such as "Could not load the specified file." 此消息会考虑当前系统区域性。This message takes into account the current system culture.

FileLoadException(SerializationInfo, StreamingContext)

使用序列化数据初始化 FileLoadException 类的新实例。Initializes a new instance of the FileLoadException class with serialized data.

FileLoadException(String)

使用指定的错误消息初始化 FileLoadException 类的新实例。Initializes a new instance of the FileLoadException class with the specified error message.

FileLoadException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 FileLoadException 类的新实例。Initializes a new instance of the FileLoadException class with a specified error message and a reference to the inner exception that is the cause of this exception.

FileLoadException(String, String)

使用指定错误信息和不能加载的文件的名称来初始化 FileLoadException 类的新实例。Initializes a new instance of the FileLoadException class with a specified error message and the name of the file that could not be loaded.

FileLoadException(String, String, Exception)

使用指定的错误信息、不能加载的文件的名称和对作为此异常原因的内部异常的引用来初始化 FileLoadException 类的新实例。Initializes a new instance of the FileLoadException class with a specified error message, the name of the file that could not be loaded, and a reference to the inner exception that is the cause of this exception.

属性

Data

获取键/值对的集合,这些键/值对提供有关该异常的其他用户定义信息。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(继承自 Exception)
FileName

获取导致该异常的文件的名称。Gets the name of the file that causes this exception.

FusionLog

获取描述程序集加载失败的原因的日志文件。Gets the log file that describes why an assembly load failed.

HelpLink

获取或设置指向与此异常关联的帮助文件链接。Gets or sets a link to the help file associated with this exception.

(继承自 Exception)
HResult

获取或设置 HRESULT(一个分配给特定异常的编码数字值)。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(继承自 Exception)
InnerException

获取导致当前异常的 Exception 实例。Gets the Exception instance that caused the current exception.

(继承自 Exception)
Message

获取错误消息和引发此异常的文件的名称。Gets the error message and the name of the file that caused this exception.

Source

获取或设置导致错误的应用程序或对象的名称。Gets or sets the name of the application or the object that causes the error.

(继承自 Exception)
StackTrace

获取调用堆栈上的即时框架字符串表示形式。Gets a string representation of the immediate frames on the call stack.

(继承自 Exception)
TargetSite

获取引发当前异常的方法。Gets the method that throws the current exception.

(继承自 Exception)

方法

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetBaseException()

当在派生类中重写时,返回 Exception,它是一个或多个并发的异常的根本原因。When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(继承自 Exception)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetObjectData(SerializationInfo, StreamingContext)

使用文件名和其他异常信息来设置 SerializationInfoSets the SerializationInfo with the file name and additional exception information.

GetType()

获取当前实例的运行时类型。Gets the runtime type of the current instance.

(继承自 Exception)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回当前异常的完全限定名,还可能返回错误信息、内部异常的名称和堆栈跟踪。Returns the fully qualified name of the current exception, and possibly the error message, the name of the inner exception, and the stack trace.

事件

SerializeObjectState

当异常被序列化用来创建包含有关该异常的徐列出数据的异常状态对象时会出现该问题。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(继承自 Exception)

适用于

另请参阅