none
CompilerParameters RRS feed

  • Pergunta

  • Boa noite, estou tentando cria um file usando codigo txt, porem me retorna erros.

     Codigo

    Imports Microsoft.CSharp
    Imports System.CodeDom.Compiler
    
    Module Module1
    
        Sub Main()
            Dim Codigo As String = "C:\Users\pjoao\Desktop\Novo Documento de Texto.txt"
            Dim FileCreate As String = "C:\Users\pjoao\Desktop\Testeteeee.exe"
    
            Dim Conpiler As New CompilerParameters({"system.dll"})
            With Conpiler
                .OutputAssembly = FileCreate
                .GenerateInMemory = True
                .TreatWarningsAsErrors = False
                .GenerateExecutable = True
                .WarningLevel = 3
                .TempFiles = New TempFileCollection(".", True)
            End With
    
            Dim cshap As CodeDomProvider = CodeDomProvider.CreateProvider("CSharp")
            Dim cr As CompilerResults = cshap.CompileAssemblyFromSource(Conpiler, Codigo)
    
            If cr.Errors.Count > 0 Then
                Console.WriteLine("Errors building {0} into {1}", _
                    Codigo, cr.PathToAssembly)
                Dim ce As CompilerError
                For Each ce In cr.Errors
                    Console.WriteLine("  {0}", ce.ToString())
                    Console.WriteLine()
                Next ce
            Else
                Console.WriteLine("Source {0} built into {1} successfully.", _
                    Codigo, cr.PathToAssembly)
                Console.WriteLine("{0} temporary files created during the compilation.", _
                        Conpiler.TempFiles.Count.ToString())
            End If
            Console.ReadLine()
        End Sub
    End Module
    

    Arquivo de texto

    Imports System
    Imports System.IO
    
    Public Class a
        Public Shared Sub main()
            MsgBox("1")
        End Sub
    End Class

    segunda-feira, 4 de junho de 2018 23:03

Respostas

Todas as Respostas