FileLoadException FileLoadException FileLoadException FileLoadException Class

定義

找到 Managed 組件但是無法載入時,所擲回的例外狀況。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.

當檔案因為找不到而無法載入時, 就會擲回例外狀況(exception)。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具有 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 Store 應用程式的 .net中, 或可移植的類別庫中, 但由的某些成員擲回。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

取得描述為什麼組件 (Assembly) 載入失敗的記錄檔。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()

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 ExceptionWhen 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 的淺層複本 (Shallow Copy)。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)

適用於

另請參閱