CompilerError クラス
アセンブリ: cscompmgd (cscompmgd.dll 内)

<ObsoleteAttribute("The recommended alternative is Microsoft.CSharp.CSharpCodeProvider and System.CodeDom.Compiler.ICodeCompiler. The CSharpCodeProvider and CodeDom ICodeCompiler provide a much richer set of functionality for specifying how to launch the compiler.")> _ Public Class CompilerError
[ObsoleteAttribute("The recommended alternative is Microsoft.CSharp.CSharpCodeProvider and System.CodeDom.Compiler.ICodeCompiler. The CSharpCodeProvider and CodeDom ICodeCompiler provide a much richer set of functionality for specifying how to launch the compiler.")] public class CompilerError
[ObsoleteAttribute(L"The recommended alternative is Microsoft.CSharp.CSharpCodeProvider and System.CodeDom.Compiler.ICodeCompiler. The CSharpCodeProvider and CodeDom ICodeCompiler provide a much richer set of functionality for specifying how to launch the compiler.")] public ref class CompilerError
/** @attribute ObsoleteAttribute("The recommended alternative is Microsoft.CSharp.CSharpCodeProvider and System.CodeDom.Compiler.ICodeCompiler. The CSharpCodeProvider and CodeDom ICodeCompiler provide a much richer set of functionality for specifying how to launch the compiler.") */ public class CompilerError
ObsoleteAttribute("The recommended alternative is Microsoft.CSharp.CSharpCodeProvider and System.CodeDom.Compiler.ICodeCompiler. The CSharpCodeProvider and CodeDom ICodeCompiler provide a much richer set of functionality for specifying how to launch the compiler.") public class CompilerError

Microsoft.CSharp.CompilerError


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CompilerError クラス
アセンブリ: System (system.dll 内)


CompilerError は、コンパイラから返されたコンパイラ エラーまたは警告を表します。
![]() |
---|
このクラスには、すべてのメンバに適用されるクラス レベルの継承確認要求が格納されます。派生クラスに完全信頼のアクセス許可がない場合、SecurityException がスローされます。継承確認要求の詳細については、「継承確認要求」を参照してください。 |

CodeDOM プログラム グラフをコンパイルし、プログラムで CompilerError データにアクセスする方法の例を次に示します。
Imports System Imports System.CodeDom Imports System.CodeDom.Compiler Imports Microsoft.CSharp Namespace CompilerError_Example _ Class Class1 Shared Sub Main() ' Output some program information using Console.WriteLine. Console.WriteLine("This program compiles a CodeDOM program that incorrectly declares multiple data") Console.WriteLine("types to demonstrate handling compiler errors programatically.") Console.WriteLine("") ' Compile the CodeCompileUnit retrieved from the GetCompileUnit() method. Dim provider As New Microsoft.CSharp.CSharpCodeProvider() ' Initialize a CompilerParameters with the options for compilation. Dim assemblies() As String = New [String]() {"System.dll"} Dim options As New CompilerParameters(assemblies, "output.exe") ' Compile the CodeDOM graph and store the results in a CompilerResults. Dim results As CompilerResults = provider.CompileAssemblyFromDom(options, GetCompileUnit()) ' Compilation produces errors. Print out each error. Console.WriteLine("Listing errors from compilation: ") Console.WriteLine("") Dim i As Integer For i = 0 To results.Errors.Count - 1 Console.WriteLine(results.Errors(i).ToString()) Next i End Sub Public Shared Function GetCompileUnit() As CodeCompileUnit ' Create a compile unit to contain a CodeDOM graph. Dim cu As New CodeCompileUnit() ' Create a namespace named TestSpace. Dim cn As New CodeNamespace("TestSpace") ' Declare a new type named TestClass. Dim cd As New CodeTypeDeclaration("TestClass") ' Declare a new member string field named TestField. Dim cmf As New CodeMemberField("System.String", "TestField") ' Add the field to the type. cd.Members.Add(cmf) ' Declare a new member method named TestMethod. Dim cm As New CodeMemberMethod() cm.Name = "TestMethod" ' Declare a string variable named TestVariable. Dim cvd As New CodeVariableDeclarationStatement("System.String1", "TestVariable") cm.Statements.Add(cvd) ' Cast the TestField reference expression to string and assign it to the TestVariable. Dim ca As New CodeAssignStatement(New CodeVariableReferenceExpression("TestVariable"), New CodeCastExpression("System.String2", New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "TestField"))) ' This code can be used to generate the following code in C#: ' TestVariable = ((string)(this.TestField)); cm.Statements.Add(ca) ' Add the TestMethod member to the TestClass type. cd.Members.Add(cm) ' Add the TestClass type to the namespace. cn.Types.Add(cd) ' Add the TestSpace namespace to the compile unit. cu.Namespaces.Add(cn) Return cu End Function End Class End Namespace
using System; using System.CodeDom; using System.CodeDom.Compiler; using Microsoft.CSharp; namespace CompilerError_Example { public class Class1 { [STAThread] static void Main(string[] args) { // Output some program information using Console.WriteLine. Console.WriteLine("This program compiles a CodeDOM program that incorrectly declares multiple data"); Console.WriteLine("types to demonstrate handling compiler errors programmatically."); Console.WriteLine(""); // Compile the CodeCompileUnit retrieved from the GetCompileUnit() method. CSharpCodeProvider provider = new Microsoft.CSharp.CSharpCodeProvider(); // Initialize a CompilerParameters with the options for compilation. string[] assemblies = new String[] {"System.dll"}; CompilerParameters options = new CompilerParameters( assemblies, "output.exe"); // Compile the CodeDOM graph and store the results in a CompilerResults. CompilerResults results = provider.CompileAssemblyFromDom(options, GetCompileUnit()); // Compilation produces errors. Print out each error. Console.WriteLine("Listing errors from compilation: "); Console.WriteLine(""); for( int i=0; i<results.Errors.Count; i++) Console.WriteLine(results.Errors[i].ToString()); } public static CodeCompileUnit GetCompileUnit() { // Create a compile unit to contain a CodeDOM graph. CodeCompileUnit cu = new CodeCompileUnit(); // Create a namespace named TestSpace. CodeNamespace cn = new CodeNamespace("TestSpace"); // Declare a new type named TestClass. CodeTypeDeclaration cd = new CodeTypeDeclaration("TestClass"); // Declare a new member string field named TestField. CodeMemberField cmf = new CodeMemberField("System.String", "TestField"); // Add the field to the type. cd.Members.Add(cmf); // Declare a new member method named TestMethod. CodeMemberMethod cm = new CodeMemberMethod(); cm.Name = "TestMethod"; // Declare a string variable named TestVariable. CodeVariableDeclarationStatement cvd = new CodeVariableDeclarationStatement("System.String1", "TestVariable"); cm.Statements.Add(cvd); // Cast the TestField reference expression to string and assign it to the TestVariable. CodeAssignStatement ca = new CodeAssignStatement(new CodeVariableReferenceExpression("TestVariable"), new CodeCastExpression("System.String2", new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "TestField"))); // This code can be used to generate the following code in C#: // TestVariable = ((string)(this.TestField)); cm.Statements.Add(ca); // Add the TestMethod member to the TestClass type. cd.Members.Add(cm); // Add the TestClass type to the namespace. cn.Types.Add(cd); // Add the TestSpace namespace to the compile unit. cu.Namespaces.Add(cn); return cu; } } }
#using <System.dll> using namespace System; using namespace System::CodeDom; using namespace System::CodeDom::Compiler; using namespace Microsoft::CSharp; CodeCompileUnit^ GetCompileUnit() { // Create a compile unit to contain a CodeDOM graph. CodeCompileUnit^ cu = gcnew CodeCompileUnit; // Create a namespace named TestSpace. CodeNamespace^ cn = gcnew CodeNamespace( "TestSpace" ); // Declare a new type named TestClass. CodeTypeDeclaration^ cd = gcnew CodeTypeDeclaration( "TestClass" ); // Declare a new member string field named TestField. CodeMemberField^ cmf = gcnew CodeMemberField( "System.String","TestField" ); // Add the field to the type. cd->Members->Add( cmf ); // Declare a new member method named TestMethod. CodeMemberMethod^ cm = gcnew CodeMemberMethod; cm->Name = "TestMethod"; // Declare a string variable named TestVariable. CodeVariableDeclarationStatement^ cvd = gcnew CodeVariableDeclarationStatement( "System.String1","TestVariable" ); cm->Statements->Add( cvd ); // Cast the TestField reference expression to string and assign it to the TestVariable. CodeAssignStatement^ ca = gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "TestVariable" ),gcnew CodeCastExpression( "System.String2",gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"TestField" ) ) ); // This code can be used to generate the following code in C#: // TestVariable = ((string)(this.TestField)); cm->Statements->Add( ca ); // Add the TestMethod member to the TestClass type. cd->Members->Add( cm ); // Add the TestClass type to the namespace. cn->Types->Add( cd ); // Add the TestSpace namespace to the compile unit. cu->Namespaces->Add( cn ); return cu; } int main() { // Output some program information using Console.WriteLine. Console::WriteLine( "This program compiles a CodeDOM program that incorrectly declares multiple data" ); Console::WriteLine( "types to demonstrate handling compiler errors programmatically." ); Console::WriteLine( "" ); // Compile the CodeCompileUnit retrieved from the GetCompileUnit() method. CSharpCodeProvider ^ provider = gcnew Microsoft::CSharp::CSharpCodeProvider; // Create a CSharpCodeCompiler. ICodeCompiler^ compiler = provider->CreateCompiler(); // Initialize a CompilerParameters with the options for compilation. array<String^>^assemblies = {"System.dll"}; CompilerParameters^ options = gcnew CompilerParameters( assemblies,"output.exe" ); // Compile the CodeDOM graph and store the results in a CompilerResults. CompilerResults^ results = compiler->CompileAssemblyFromDom( options, GetCompileUnit() ); // Compilation produces errors. Print out each error. Console::WriteLine( "Listing errors from compilation: " ); Console::WriteLine( "" ); for ( int i = 0; i < results->Errors->Count; i++ ) Console::WriteLine( results->Errors[ i ] ); }


System.CodeDom.Compiler.CompilerError


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CompilerError コンストラクタ ()
アセンブリ: System (system.dll 内)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CompilerError コンストラクタ (String, Int32, Int32, String, String)
アセンブリ: System (system.dll 内)

Public Sub New ( _ fileName As String, _ line As Integer, _ column As Integer, _ errorNumber As String, _ errorText As String _ )
Dim fileName As String Dim line As Integer Dim column As Integer Dim errorNumber As String Dim errorText As String Dim instance As New CompilerError(fileName, line, column, errorNumber, errorText)
public CompilerError ( string fileName, int line, int column, string errorNumber, string errorText )
public: CompilerError ( String^ fileName, int line, int column, String^ errorNumber, String^ errorText )
public CompilerError ( String fileName, int line, int column, String errorNumber, String errorText )
public function CompilerError ( fileName : String, line : int, column : int, errorNumber : String, errorText : String )

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CompilerError コンストラクタ
アセンブリ: cscompmgd (cscompmgd.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CompilerError コンストラクタ

名前 | 説明 |
---|---|
CompilerError () | CompilerError クラスの新しいインスタンスを初期化します。 |
CompilerError (String, Int32, Int32, String, String) | ファイル名、行、列、エラー番号、およびエラー テキストを指定して、CompilerError クラスの新しいインスタンスを初期化します。 |

CompilerError フィールド
CompilerError プロパティ

名前 | 説明 | |
---|---|---|
![]() | Column | エラーの原因となった列の番号を取得または設定します。 |
![]() | ErrorNumber | エラー番号を取得または設定します。 |
![]() | ErrorText | エラー メッセージのテキストを取得または設定します。 |
![]() | FileName | エラーの原因となったコードが含まれるソース ファイルのファイル名を取得または設定します。 |
![]() | IsWarning | エラーが警告かどうかを示す値を取得または設定します。 |
![]() | Line | エラーの原因となった行の番号を取得または設定します。 |

CompilerError メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | オーバーライドされます。 |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

CompilerError メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | オーバーライドされます。 オブジェクトの ToString メソッドの実装を提供します。 |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

CompilerError メンバ
CompilerError データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | CompilerError |

名前 | 説明 | |
---|---|---|
![]() | ErrorLevel | |
![]() | ErrorMessage | |
![]() | ErrorNumber | |
![]() | SourceColumn | |
![]() | SourceFile | |
![]() | SourceLine |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | オーバーライドされます。 |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

CompilerError メンバ
CompilerError データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Column | エラーの原因となった列の番号を取得または設定します。 |
![]() | ErrorNumber | エラー番号を取得または設定します。 |
![]() | ErrorText | エラー メッセージのテキストを取得または設定します。 |
![]() | FileName | エラーの原因となったコードが含まれるソース ファイルのファイル名を取得または設定します。 |
![]() | IsWarning | エラーが警告かどうかを示す値を取得または設定します。 |
![]() | Line | エラーの原因となった行の番号を取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | オーバーライドされます。 オブジェクトの ToString メソッドの実装を提供します。 |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- CompilerErrorのページへのリンク