MissingSatelliteAssemblyException クラス

定義

既定のカルチャのリソースのサテライト アセンブリが見つからない場合にスローされる例外。

public ref class MissingSatelliteAssemblyException : SystemException
public class MissingSatelliteAssemblyException : SystemException
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class MissingSatelliteAssemblyException : SystemException
type MissingSatelliteAssemblyException = class
    inherit SystemException
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type MissingSatelliteAssemblyException = class
    inherit SystemException
Public Class MissingSatelliteAssemblyException
Inherits SystemException
継承
MissingSatelliteAssemblyException
属性

次の例では、この属性を NeutralResourcesLanguageAttribute 使用して、英語がアプリの既定のカルチャであり、そのリソースがサテライト アセンブリに格納されていることを示します。 この例自体には、次の表に示すように、英語とフランス語のカルチャの.txt ファイル内のリソースが含まれています。

カルチャ リソース名/値 ファイル名
英語 Greet=Hello Greet.en.txt
フランス語 Greet=Bonjour Greet.fr.txt

次のソース コードは、現在の UI カルチャを最初にフランス語 (フランス) に、次にロシア語 (ロシア) に変更し、どちらの場合も適切なカルチャ固有のリソースを表示するアプリをビルドします。

using System;
using System.Globalization;
using System.Resources;
using System.Threading;

[assembly:NeutralResourcesLanguageAttribute("en", UltimateResourceFallbackLocation.Satellite)]

public class Example
{
   public static void Main()
   {
      ResourceManager rm = new ResourceManager("GreetResources", typeof(Example).Assembly); 
      Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("fr-FR");
      Console.WriteLine("The current UI culture is {0}", Thread.CurrentThread.CurrentUICulture.Name);
      Console.WriteLine(rm.GetString("Greet"));
      
      Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("ru-RU");
      Console.WriteLine("The current UI culture is {0}", Thread.CurrentThread.CurrentUICulture.Name);
      Console.WriteLine(rm.GetString("Greet"));
   }
}
// The example displays the following output when created using BuildNoDefault.bat: 
//    The current UI culture is fr-FR
//    Bonjour
//    The current UI culture is ru-RU
//    
//    Unhandled Exception: System.Resources.MissingSatelliteAssemblyException: 
//    The satellite assembly named "HelloWorld.resources.dll, PublicKeyToken=" for fallback culture 
//    "en" either could not be found or could not be loaded. This is generally a setup problem. 
//    Please consider reinstalling or repairing the application.
//       at System.Resources.ManifestBasedResourceGroveler.HandleSatelliteMissing()
//       at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo cult
//    ure, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackC
//    rawlMark& stackMark)
//       at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture
//    , Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
//       at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean
//     createIfNotExists, Boolean tryParents)
//       at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
//       at Example.Main()
// The example displays the following output when created using BuildDefault.bat:
//    The current UI culture is fr-FR
//    Bonjour
//    The current UI culture is ru-RU
//    Hello
Imports System.Globalization
Imports System.Resources
Imports System.Threading

<assembly:NeutralResourcesLanguageAttribute("en", UltimateResourceFallbackLocation.Satellite)>

Module Example
   Public Sub Main()
      Dim rm As New ResourceManager("GreetResources", GetType(Example).Assembly) 
      Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("fr-FR")
      Console.WriteLine("The current UI culture is {0}", Thread.CurrentThread.CurrentUICulture.Name)
      Console.WriteLine(rm.GetString("Greet"))
      
      Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("ru-RU")
      Console.WriteLine("The current UI culture is {0}", Thread.CurrentThread.CurrentUICulture.Name)
      Console.WriteLine(rm.GetString("Greet"))
   End Sub
End Module
' The example displays the following output:
'    The current UI culture is fr-FR
'    Bonjour
'    The current UI culture is ru-RU
'    
'    Unhandled Exception: System.Resources.MissingSatelliteAssemblyException: 
'    The satellite assembly named "HelloWorld.resources.dll, PublicKeyToken=" for fallback culture 
'    "en" either could not be found or could not be loaded. This is generally a setup problem. 
'    Please consider reinstalling or repairing the application.
'       at System.Resources.ManifestBasedResourceGroveler.HandleSatelliteMissing()
'       at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo cult
'    ure, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackC
'    rawlMark& stackMark)
'       at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture
'    , Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
'       at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean
'     createIfNotExists, Boolean tryParents)
'       at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
'       at Example.Main()
' The example displays the following output when created using BuildDefault.bat:
'    The current UI culture is fr-FR
'    Bonjour
'    The current UI culture is ru-RU
'    Hello

次のバッチ ファイルを使用して、C# バージョンの例をビルドして実行できます。 Visual Basic を使用している場合は、cscvbc に置換し、.cs 拡張子を .vb に置換します。 この例を実行すると、フランス語の文字列が表示されますが、現在の MissingSatelliteAssemblyException カルチャがロシア語 (ロシア) の場合は例外がスローされます。 これは、既定のカルチャのリソースを含むサテライト アセンブリ en\HelloWorld.dllが存在しないためです。

vbc HelloWorld.vb  

md fr  
resgen Greet.fr.txt  
al /out:fr\HelloWorld.resources.dll /culture:fr /embed:GreetResources.fr.resources  

HelloWorld  

次のバッチ ファイルを使用して、Visual Basic バージョンの例をビルドして実行できます。 C# を使用している場合は、次のようにcsc置き換えvbc、拡張子.cs.vb . で置き換えます。 この例を実行すると、現在の UI カルチャがフランス語 (フランス) の場合、フランス語の文字列が表示されます。 現在の UI カルチャがロシア語 (ロシア語) の場合、ロシア語のリソースが存在しないため、英語の文字列が表示されますが、リソース マネージャーはサテライト アセンブリ en\HelloWorld2.dllから既定のカルチャのリソースを読み込むことができます。

vbc HelloWorld.vb /out:HelloWorld2.exe  

md fr  
resgen GreetResources.fr.txt  
al /out:fr\HelloWorld2.resources.dll /culture:fr /embed:GreetResources.fr.resources  

md en  
resgen GreetResources.en.txt  
al /out:en\HelloWorld2.resources.dll /culture:en /embed:GreetResources.en.resources  

HelloWorld2  

注釈

既定のカルチャは、適切なカルチャ固有のリソースが見つからない場合にリソースが読み込まれるカルチャです。 既定では、既定のカルチャのリソースはメイン アセンブリに配置され MissingManifestResourceException 、リソース マネージャーが取得を試みたが、既定のカルチャのリソースが見つからない場合は a がスローされます。 ただし、属性で location パラメーターの値が指定されている場合NeutralResourcesLanguageAttribute、.NET Frameworkはサテライト アセンブリからアプリの既定のカルチャのUltimateResourceFallbackLocation.Satelliteリソースを読み込みます。 この場合、 MissingSatelliteAssemblyException リソース マネージャーが既定のカルチャのリソースを取得しようとしたときに例外がスローされ、属性で NeutralResourcesLanguageAttribute 指定されたカルチャのサテライト アセンブリが見つかりません。 例外は、オブジェクトがインスタンス化されたときResourceManagerではなく、リソース取得メソッド (または ResourceManager.GetObject、 などResourceManager.GetString) によってスローされることに注意してください。

MissingSatelliteAssemblyException は、0x80131536値を持つ HRESULT COR_E_MISSINGSATELLITEASSEMBLYを使用します。

MissingSatelliteAssemblyException は、参照の等価性をサポートする既定 Equals の実装を使用します。

クラスのインスタンスの初期プロパティ値の MissingSatelliteAssemblyException 一覧については、コンストラクターを MissingSatelliteAssemblyException 参照してください。

注意

この属性を NeutralResourcesLanguageAttribute 使用してアプリの既定のカルチャを定義し、特定のカルチャのリソースが使用できない場合、アプリケーションで許容される動作が表示されるようにする必要があります。

コンストラクター

MissingSatelliteAssemblyException()

MissingSatelliteAssemblyException クラスの新しいインスタンスを、既定のプロパティを使用して初期化します。

MissingSatelliteAssemblyException(SerializationInfo, StreamingContext)

シリアル化したデータから、MissingSatelliteAssemblyException クラスの新しいインスタンスを初期化します。

MissingSatelliteAssemblyException(String)

指定されたエラー メッセージで MissingSatelliteAssemblyException クラスの新しいインスタンスを初期化します。

MissingSatelliteAssemblyException(String, Exception)

指定したエラー メッセージおよびこの例外の原因となった内部例外への参照を使用して、MissingSatelliteAssemblyException クラスの新しいインスタンスを初期化します。

MissingSatelliteAssemblyException(String, String)

指定したエラー メッセージとニュートラル カルチャの名前を使用して、MissingSatelliteAssemblyException クラスの新しいインスタンスを初期化します。

プロパティ

CultureName

既定のカルチャの名前を取得します。

Data

例外に関する追加のユーザー定義情報を提供する、キーと値のペアのコレクションを取得します。

(継承元 Exception)
HelpLink

この例外に関連付けられているヘルプ ファイルへのリンクを取得または設定します。

(継承元 Exception)
HResult

特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。

(継承元 Exception)
InnerException

現在の例外の原因となる Exception インスタンスを取得します。

(継承元 Exception)
Message

現在の例外を説明するメッセージを取得します。

(継承元 Exception)
Source

エラーの原因となるアプリケーションまたはオブジェクトの名前を取得または設定します。

(継承元 Exception)
StackTrace

呼び出し履歴で直前のフレームの文字列形式を取得します。

(継承元 Exception)
TargetSite

現在の例外がスローされたメソッドを取得します。

(継承元 Exception)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetBaseException()

派生クラスでオーバーライドされた場合、それ以後に発生する 1 つ以上の例外の根本原因である Exception を返します。

(継承元 Exception)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetObjectData(SerializationInfo, StreamingContext)

派生クラスでオーバーライドされた場合は、その例外に関する情報を使用して SerializationInfo を設定します。

(継承元 Exception)
GetType()

現在のインスタンスのランタイム型を取得します。

(継承元 Exception)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在の例外の文字列形式を作成して返します。

(継承元 Exception)

events

SerializeObjectState
互換性のために残されています。

例外がシリアル化され、例外に関するシリアル化されたデータを含む例外状態オブジェクトが作成されたときに発生します。

(継承元 Exception)

適用対象

こちらもご覧ください