Olvasás angol nyelven Szerkesztés

Megosztás a következőn keresztül:


ModuleBuilder.DefineDocument Method

Definition

Overloads

DefineDocument(String, Guid)

Defines a document for source.

DefineDocument(String, Guid, Guid, Guid)

Defines a document for source.

DefineDocument(String, Guid)

Defines a document for source.

C#
public System.Diagnostics.SymbolStore.ISymbolDocumentWriter DefineDocument(string url, Guid language = default);

Parameters

url
String

The URL for the document.

language
Guid

The GUID that identifies the document language. This is optional.

Returns

The defined document.

Exceptions

url is null.

This method is called on a dynamic module that is not a persisted module.

Applies to

.NET 10 és .NET 9
Termék Verziók
.NET 9, 10

DefineDocument(String, Guid, Guid, Guid)

Defines a document for source.

C#
public System.Diagnostics.SymbolStore.ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType);

Parameters

url
String

The URL for the document.

language
Guid

The GUID that identifies the document language. This can be Empty.

languageVendor
Guid

The GUID that identifies the document language vendor. This can be Empty.

documentType
Guid

The GUID that identifies the document type. This can be Empty.

Returns

The defined document.

Exceptions

url is null. This is a change from earlier versions of the .NET Framework.

This method is called on a dynamic module that is not a debug module.

Examples

The following code sample illustrates the use of DefineDocument to attach an external symbol document (in this case, a raw IL file) to a dynamic module.

C#
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Diagnostics.SymbolStore;

namespace ILGenServer
{
   public class CodeGenerator
   {
      ModuleBuilder myModuleBuilder ;
      AssemblyBuilder myAssemblyBuilder ;

      public CodeGenerator()
      {

         // Get the current application domain for the current thread.
         AppDomain currentDomain = AppDomain.CurrentDomain;
         AssemblyName myAssemblyName = new AssemblyName();
         myAssemblyName.Name = "TempAssembly";

         // Define a dynamic assembly in the current domain.
         myAssemblyBuilder =
            currentDomain.DefineDynamicAssembly
                        (myAssemblyName, AssemblyBuilderAccess.RunAndSave);
         // Define a dynamic module in "TempAssembly" assembly.
         myModuleBuilder =
            myAssemblyBuilder.DefineDynamicModule("TempModule","Resource.mod",true);

         // Define a document for source.on 'TempModule' module.
         ISymbolDocumentWriter myDocument =
         myModuleBuilder.DefineDocument("RTAsm.il", SymDocumentType.Text,
                  SymLanguageType.ILAssembly,SymLanguageVendor.Microsoft);

         Console.WriteLine("The object representing the defined document is:"+myDocument);
      }
   }
   public class CallerClass
   {
      public static void Main()
      {
         CodeGenerator myGenerator = new CodeGenerator();
      }
   }
}

Remarks

Fontos

Earlier versions of the .NET Framework throw ArgumentException instead of ArgumentNullException when url is null.

Applies to

.NET 10 és más verziók
Termék Verziók
.NET 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1