MissingManifestResourceException 類別


如果主要組件沒有包含中性文化特性 (Culture) 的資源,且遺漏適當的附屬組件,所擲回的例外狀況。The exception that is thrown if the main assembly does not contain the resources for the neutral culture, and an appropriate satellite assembly is missing.

public ref class MissingManifestResourceException : SystemException
public class MissingManifestResourceException : SystemException
type MissingManifestResourceException = class
    inherit SystemException
Public Class MissingManifestResourceException
Inherits SystemException


.NET 應用程式.NET apps

在 .NET Framework 和 .NET Core 應用程式中,當嘗試捕獲資源失敗時,會擲回 MissingManifestResourceException,因為無法從特定元件載入中性文化特性的資源集。In .NET Framework and .NET Core apps, MissingManifestResourceException is thrown when the attempt to retrieve a resource fails because the resource set for the neutral culture could not be loaded from a particular assembly. 雖然當您嘗試抓取特定資源時,會擲回例外狀況,但它是因為載入資源集而不是找出資源失敗所造成。Although the exception is thrown when you try to retrieve a particular resource, it is caused by the failure to load the resource set rather than the failure to find the resource.


如需詳細資訊,請參閱 ResourceManager 類別主題中的「處理 System.resources.missingmanifestresourceexception 例外狀況」一節。For additional information, see the "Handling a MissingManifestResourceException Exception" section in the ResourceManager class topic.

例外狀況的主要原因包括下列各項:The main causes of the exception include the following:

  • 資源集不是由其完整名稱所識別。The resource set is not identified by its fully qualified name. 例如,如果呼叫 ResourceManager.ResourceManager(String, Assembly) 方法中的 baseName 參數指定不含命名空間之資源集的根名稱,但資源集是在儲存在其元件中時指派,則對 ResourceManager.GetString 方法的呼叫會擲回這個例外狀況。For example, if the baseName parameter in the call to the ResourceManager.ResourceManager(String, Assembly) method specifies the root name of the resource set without a namespace, but the resource set is assigned a namespace when it is stored in its assembly, the call to the ResourceManager.GetString method throws this exception.

    如果您已將包含預設文化特性資源的 .resources 檔案內嵌在可執行檔中,而您的應用程式擲回 MissingManifestResourceException,您可以使用反映工具(例如IL 解譯器(Ildasm))來判斷資源的完整名稱。If you have embedded the .resources file that contains the default culture's resources in your executable and your app is throwing a MissingManifestResourceException, you can use a reflection tool such as the IL Disassembler (Ildasm.exe) to determine the fully qualified name of the resource. 在 [ILDasm] 中,按兩下可執行檔的資訊清單標籤以開啟資訊清單視窗。In ILDasm, double click the executable's MANIFEST label to open the MANIFEST window. 資源會顯示為 .mresource 專案,而且會在外部元件參考和自訂群組件層級屬性之後列出。Resources appear as .mresource items and are listed after external assembly references and custom assembly-level attributes. 您也可以編譯下列簡單的公用程式,其中會列出元件中內嵌資源的完整名稱,其名稱會以命令列參數的形式傳遞給它。You can also compile the following simple utility, which lists the fully qualified names of embedded resources in the assembly whose name is passed to it as a command-line parameter.

    using System;
    using System.IO;
    using System.Reflection;
    using System.Resources;
    public class Example
       public static void Main()
          if (Environment.GetCommandLineArgs().Length == 1) { 
             Console.WriteLine("No filename.");
          string filename = Environment.GetCommandLineArgs()[1].Trim();
          // Check whether the file exists.
          if (! File.Exists(filename)) {
             Console.WriteLine("{0} does not exist.", filename);
          // Try to load the assembly.
          Assembly assem = Assembly.LoadFrom(filename);
          Console.WriteLine("File: {0}", filename);
          // Enumerate the resource files.
          string[] resNames = assem.GetManifestResourceNames();
          if (resNames.Length == 0)
             Console.WriteLine("   No resources found.");
          foreach (var resName in resNames)
             Console.WriteLine("   Resource: {0}", resName.Replace(".resources", ""));
    Imports System.IO
    Imports System.Reflection
    Imports System.Resources
    Module Example
       Public Sub Main()
          If Environment.GetCommandLineArgs.Length = 1 Then 
             Console.WriteLine("No filename.")
             Exit Sub
          End If
          Dim filename As String = Environment.GetCommandLineArgs(1).Trim()
          ' Check whether the file exists.
          If Not File.Exists(filename) Then
             Console.WriteLine("{0} does not exist.", filename)
             Exit Sub
          End If   
          ' Try to load the assembly.
          Dim assem As Assembly = Assembly.LoadFrom(filename)
          Console.WriteLine("File: {0}", filename)
          ' Enumerate the resource files.
          Dim resNames() As String = assem.GetManifestResourceNames()
          If resNames.Length = 0 Then
             Console.WriteLine("   No resources found.")
          End If
          For Each resName In resNames
             Console.WriteLine("   Resource: {0}", resName.Replace(".resources", ""))
       End Sub
    End Module
  • 您可以依據資源檔名稱(連同其選擇性命名空間)及其副檔名(而不是單獨使用其命名空間和根檔案名)來識別資源集。You identify the resource set by its resource file name (along with its optional namespace) and its file extension rather than by its namespace and root file name alone. 例如,如果中性文化特性的資源集命名為 GlobalResources,而您將 GlobalResources.resources (而不是 GlobalResources)的值提供給 ResourceManager.ResourceManager(String, Assembly) 函式的 baseName 參數,就會擲回這個例外狀況。For example, this exception is thrown if the neutral culture's resource set is named GlobalResources and you supply a value of GlobalResources.resources (instead of GlobalResources) to the baseName parameter of the ResourceManager.ResourceManager(String, Assembly) constructor.

  • 找不到在方法呼叫中識別的特定文化特性資源集,而且無法載入回溯資源集。The culture-specific resource set that is identified in a method call cannot be found, and the fallback resource set cannot be loaded. 例如,如果您建立英文(美國)和俄羅斯(俄文)文化特性的附屬元件,但無法提供中性文化特性的資源集,則如果應用程式目前的文化特性是英文(英國),就會擲回此例外狀況。For example, if you create satellite assemblies for the English (United States) and Russia (Russian) cultures but you fail to provide a resource set for the neutral culture, this exception is thrown if your app's current culture is English (Great Britain).

MissingManifestResourceException 使用 HRESULT COR_E_MISSINGMANIFESTRESOURCE,其值為0x80131532。MissingManifestResourceException uses the HRESULT COR_E_MISSINGMANIFESTRESOURCE, which has the value 0x80131532.

MissingManifestResourceException 使用預設的 Equals 實值,其支援參考相等。MissingManifestResourceException uses the default Equals implementation, which supports reference equality.

如需執行個體的初始屬性值的清單MissingManifestResourceException,請參閱MissingManifestResourceException建構函式。For a list of initial property values for an instance of MissingManifestResourceException, see the MissingManifestResourceException constructors.


我們建議您在主要元件中包含一組中性的資源,因此如果無法使用附屬元件,您的應用程式將不會失敗。We recommend that you include a neutral set of resources in your main assembly, so your app won't fail if a satellite assembly is unavailable.

通用 Windows 平臺(UWP)應用程式Universal Windows Platform (UWP) apps

UWP 應用程式會在單一套件資源索引(pri)檔案中,部署多個文化特性的資源,包括中性文化特性。UWP apps deploy resources for multiple cultures, including the neutral culture, in a single package resource index (.pri) file. 因此,在 UWP 應用程式中,如果找不到慣用文化特性的資源,則會在下列任一情況下擲回 MissingManifestResourceExceptionAs a result, in a UWP app, if resources for the preferred culture cannot be found, the MissingManifestResourceException is thrown under either of the following conditions:

  • 應用程式不包含 pri 檔案,或無法開啟 pri 檔案。The app does not include a .pri file, or the .pri file could not be opened.

  • 應用程式的 pri 檔案不包含指定根名稱的資源集。The app's .pri file does not contain a resource set for the given root name.



使用預設屬性,初始化 MissingManifestResourceException 類別的新執行個體。Initializes a new instance of the MissingManifestResourceException class with default properties.

MissingManifestResourceException(SerializationInfo, StreamingContext)

從序列化資料中,初始化 MissingManifestResourceException 類別的新執行個體。Initializes a new instance of the MissingManifestResourceException class from serialized data.


使用指定的錯誤訊息,初始化 MissingManifestResourceException 類別的新執行個體。Initializes a new instance of the MissingManifestResourceException class with the specified error message.

MissingManifestResourceException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 MissingManifestResourceException 類別的新執行個體。Initializes a new instance of the MissingManifestResourceException class with a specified error message and a reference to the inner exception that is the cause of this exception.



取得提供例外狀況之其他使用者定義相關資訊的索引鍵/值組集合。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(繼承來源 Exception)

取得或設定與這個例外狀況相關聯的說明檔連結。Gets or sets a link to the help file associated with this exception.

(繼承來源 Exception)

取得或設定 HRESULT,它是指派給特定例外狀況的編碼數值。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(繼承來源 Exception)

取得造成目前例外狀況的 Exception 執行個體。Gets the Exception instance that caused the current exception.

(繼承來源 Exception)

取得描述目前例外狀況的訊息。Gets a message that describes the current exception.

(繼承來源 Exception)

取得或設定造成錯誤的應用程式或物件的名稱。Gets or sets the name of the application or the object that causes the error.

(繼承來源 Exception)

取得呼叫堆疊上即時運算框架的字串表示。Gets a string representation of the immediate frames on the call stack.

(繼承來源 Exception)

取得擲回目前例外狀況的方法。Gets the method that throws the current exception.

(繼承來源 Exception)



判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 ExceptionWhen overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(繼承來源 Exception)

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetObjectData(SerializationInfo, StreamingContext)

在衍生類別中覆寫時,使用例外狀況的資訊設定 SerializationInfoWhen overridden in a derived class, sets the SerializationInfo with information about the exception.

(繼承來源 Exception)

取得目前執行個體的執行階段類型。Gets the runtime type of the current instance.

(繼承來源 Exception)

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)

建立並傳回目前例外狀況的字串表示。Creates and returns a string representation of the current exception.

(繼承來源 Exception)



當例外狀況序列化,以建立包含例外狀況相關序列化資料的例外狀況狀態物件時,就會發生此事件。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(繼承來源 Exception)