TypeLoadException.Message プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TypeLoadException.Message プロパティの意味・解説 

TypeLoadException.Message プロパティ

この例外エラー メッセージ取得します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説
使用例使用例

mscorlib アセンブリから存在しない型の読み込み試みる例を次に示しますスローされる例外キャッチされ、TypeNameMessage の値が表示されます。このコード例実行するには、アセンブリの完全限定名を指定する必要がありますアセンブリの完全限定名を取得する方法については、「アセンブリ名」を参照してください

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class Example
   Public Shared Sub Main()
      ' Get a reference to the assembly mscorlib.dll, which is always
      ' loaded. (System.String is defined in mscorlib.)
      Dim tString As Type = GetType(String)
      Dim mscorlib As [Assembly] = tString.Assembly

      Try
         Console.WriteLine("Attempting to load a type that does
 not exist in mscorlib.")
         ' The boolean parameter causes an exception to be thrown if
 the
         ' type is not found.
         Dim myType As Type = mscorlib.GetType("System.NonExistentType",
 True)
      Catch ex As TypeLoadException
         ' Display the name of the type that was not found, and the
 
         ' exception message.
         Console.WriteLine("TypeLoadException was caught. Type = '{0}'.",
 _
             ex.TypeName)
         Console.WriteLine("Error Message = '{0}'", ex.Message)
      End Try
   End Sub 
End Class 
'
' This example produces output similar to the following:
'
'Attempting to load a type that does not exist in mscorlib.
'TypeLoadException was caught. Type = 'System.NonExistentType'
'Error Message = 'Could not load type System.NonExistentType from assembly
 mscorl
'ib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.'
using System;
using System.Reflection;

public class TypeLoadException_TypeName
{
   public static void Main()
 
   {
      // Get a reference to the assembly mscorlib.dll, which is always
      // loaded. (System.String is defined in mscorlib.)
      Assembly mscorlib = typeof(string).Assembly;

      try 
      {
         Console.WriteLine("Attempting to load a type that does not exist in
 mscorlib.");
         // The boolean parameter causes an exception to be thrown if
 the
         // type is not found.
         Type myType = mscorlib.GetType("System.NonExistentType", true);
      }  
      catch (TypeLoadException ex) 
      {
         // Display the name of the type that was not found, and the
 
         // exception message.
         Console.WriteLine("TypeLoadException was caught. Type = '{0}'.",
 
             ex.TypeName);
         Console.WriteLine("Error Message = '{0}'", ex.Message);
      }  
   }
}
/*
 This code example produces output similar to the following:

Attempting to load a type that does not exist in mscorlib.
TypeLoadException was caught. Type = 'System.NonExistentType'
Error Message = 'Could not load type System.NonExistentType from assembly mscorl
ib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.'
 */
// Load the mscorlib assembly and get a reference to it.
// You must supply the fully qualified assembly name for mscorlib.dll
 here.
Assembly^ myAssembly = Assembly::Load( "Assembly text name, Version, Culture,
 PublicKeyToken" );
try
{
   Console::WriteLine( "This program throws an exception upon successful run."
 );
   
   // Attempt to load a non-existent type from an assembly. 
   Type^ myType = myAssembly->GetType( "System.NonExistentType", true
 );
}
catch ( TypeLoadException^ e ) 
{
   // Display the name of the Type that was not found.
   Console::WriteLine( "TypeLoadException: \n\tError loading the type '{0}'
 from the assembly 'mscorlib'", e->TypeName );
   Console::WriteLine( "\tError Message = {0}", e->Message );
}
catch ( Exception^ e ) 
{
   Console::WriteLine( "Exception: Error Message = {0}", e->Message
 );
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TypeLoadException クラス
TypeLoadException メンバ
System 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TypeLoadException.Message プロパティ」の関連用語

TypeLoadException.Message プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TypeLoadException.Message プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS