Compartir a través de


ModuleBuilder.DefineDocument Método

Definición

Sobrecargas

DefineDocument(String, Guid)

Define un documento para el origen.

DefineDocument(String, Guid, Guid, Guid)

Define un documento para el origen.

DefineDocument(String, Guid)

Define un documento para el origen.

public System.Diagnostics.SymbolStore.ISymbolDocumentWriter DefineDocument (string url, Guid language = default);
member this.DefineDocument : string * Guid -> System.Diagnostics.SymbolStore.ISymbolDocumentWriter
Public Function DefineDocument (url As String, Optional language As Guid = Nothing) As ISymbolDocumentWriter

Parámetros

url
String

Dirección URL del documento.

language
Guid

GUID que identifica el idioma del documento. Esto es opcional.

Devoluciones

Documento definido.

Excepciones

url es null.

Se llama a este método en un módulo dinámico que no es un módulo persistente.

Se aplica a

DefineDocument(String, Guid, Guid, Guid)

Define un documento para el origen.

public:
 System::Diagnostics::SymbolStore::ISymbolDocumentWriter ^ DefineDocument(System::String ^ url, Guid language, Guid languageVendor, Guid documentType);
public System.Diagnostics.SymbolStore.ISymbolDocumentWriter DefineDocument (string url, Guid language, Guid languageVendor, Guid documentType);
member this.DefineDocument : string * Guid * Guid * Guid -> System.Diagnostics.SymbolStore.ISymbolDocumentWriter
Public Function DefineDocument (url As String, language As Guid, languageVendor As Guid, documentType As Guid) As ISymbolDocumentWriter

Parámetros

url
String

Dirección URL del documento.

language
Guid

GUID que identifica el idioma del documento. Esto puede ser Empty.

languageVendor
Guid

GUID que identifica al proveedor del idioma del documento. Esto puede ser Empty.

documentType
Guid

GUID que identifica el tipo de documento. Esto puede ser Empty.

Devoluciones

Documento definido.

Excepciones

url es null. Se trata de un cambio de versiones anteriores de .NET Framework.

Se llama a este método en un módulo dinámico que no es un módulo de depuración.

Ejemplos

En el ejemplo de código siguiente se muestra el uso de DefineDocument para adjuntar un documento de símbolos externo (en este caso, un archivo IL sin formato) a un módulo dinámico.

using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
using namespace System::Resources;
using namespace System::Diagnostics::SymbolStore;
public ref class CodeGenerator
{
private:
   ModuleBuilder^ myModuleBuilder;
   AssemblyBuilder^ myAssemblyBuilder;

public:
   CodeGenerator()
   {
      
      // Get the current application domain for the current thread.
      AppDomain^ currentDomain = AppDomain::CurrentDomain;
      AssemblyName^ myAssemblyName = gcnew AssemblyName;
      myAssemblyName->Name = "TempAssembly";
      
      // Define a dynamic assembly in the current domain.
      myAssemblyBuilder = currentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::RunAndSave );
      
      // Define a dynamic module in S"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: {0}", myDocument );
   }

};

int main()
{
   CodeGenerator^ myGenerator = gcnew CodeGenerator;
}
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();
      }
   }
}
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Resources
Imports System.Diagnostics.SymbolStore

Namespace ILGenServer

   Public Class CodeGenerator
      Private myModuleBuilder As ModuleBuilder
      Private myAssemblyBuilder As AssemblyBuilder

      Public Sub New()

         ' Get the current application domain for the current thread.
         Dim currentDomain As AppDomain = AppDomain.CurrentDomain
         Dim myAssemblyName As 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.
         Dim myDocument As ISymbolDocumentWriter = myModuleBuilder.DefineDocument("RTAsm.il", _
                     SymDocumentType.Text, SymLanguageType.ILAssembly, SymLanguageVendor.Microsoft)
         Console.WriteLine("The object representing the defined document is:" + _
                                                             CObj(myDocument).ToString())

      End Sub
   End Class

   Public Class CallerClass

      Public Shared Sub Main()
         Dim myGenerator As New CodeGenerator()
      End Sub
   End Class
End Namespace 'ILGenServer

Comentarios

Importante

Las versiones anteriores de .NET Framework inician ArgumentException en lugar de ArgumentNullException cuando url es null.

Se aplica a