FileLoadException FileLoadException FileLoadException FileLoadException Class

定义

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

public ref 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
继承
属性

注解

表示在Assembly找到但无法加载文件时发生的错误。Represents the error that occurs when a Assembly file is found but cannot be loaded.

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

FileLoadException具有值为0x80131621 的 COR_E_FILELOAD 的默认 HRESULT, 但这不是唯一可能的 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. 若要在这种情况下捕获异常, catch请改IOException为编写一条语句。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() FileLoadException() 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(SerializationInfo, StreamingContext) FileLoadException(SerializationInfo, StreamingContext) FileLoadException(SerializationInfo, StreamingContext)

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

FileLoadException(String) FileLoadException(String) FileLoadException(String) FileLoadException(String)

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

FileLoadException(String, Exception) FileLoadException(String, Exception) FileLoadException(String, Exception) 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(String, String) FileLoadException(String, String) 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(String, String, Exception) FileLoadException(String, String, Exception) 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 Data Data Data

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

(Inherited from Exception)
FileName FileName FileName FileName

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

FusionLog FusionLog FusionLog FusionLog

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

HelpLink HelpLink HelpLink HelpLink

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

(Inherited from Exception)
HResult HResult HResult HResult

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

(Inherited from Exception)
InnerException InnerException InnerException InnerException

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

(Inherited from Exception)
Message Message Message Message

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

Source Source Source Source

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

(Inherited from Exception)
StackTrace StackTrace StackTrace StackTrace

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

(Inherited from Exception)
TargetSite TargetSite TargetSite TargetSite

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

(Inherited from Exception)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetBaseException() GetBaseException() GetBaseException() GetBaseException()

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

(Inherited from Exception)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

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

GetType() GetType() GetType() GetType()

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

(Inherited from Exception)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
ToString() ToString() ToString() 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 SerializeObjectState SerializeObjectState SerializeObjectState

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

(Inherited from Exception)

适用于

另请参阅