none
Caractères non conformes dans le chemin d'accès ... RRS feed

  • Discussion générale

  • Salut tt le monde,

    je suis entrain de dévellopper un programme en visual basic 2010 (CodeDom Compiler) ... j'ai un bouton en dessous d'une richtextbox contenat un code à compiler

    Lorsque j'appuie sur le boutton je veux que le compileur prend le code de la richtextbox mais cela n'a pas fonctionner avec moi sachant que je peux faire le meme processus avec un fichier txt ou un fichier en ressource !

    Voici mon code : 

    Option Strict On
    Imports System.IO
    Imports System.Reflection
    Imports System.CodeDom
    Imports System.CodeDom.Compiler
    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Windows.Forms
    Imports System.Text
    Imports System.Runtime.InteropServices
    Imports System.Security.Cryptography
    Imports System.Runtime.CompilerServices
    Imports System.IO.FileStream
    Imports System.ComponentModel
    Imports Microsoft.Win32
    Imports System.Diagnostics
    Imports System.Object
    Imports System.Net
    Imports System.Threading.Thread
    Imports System.Environment
    
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            NotifyIcon1.ShowBalloonTip(1000)
        End Sub
    
        Private Sub CrystalClearButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalClearButton3.Click
            My.Computer.Audio.Play(My.Resources.click_one, AudioPlayMode.Background)
            With SaveFileDialog1
                .Filter = "EXE Files (*.exe)|*.exe"
                .Title = "Save Final Project ..."
                .InitialDirectory = "%Desktop%"
                If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                    CodeDomCompiler.Compile(SaveFileDialog1.FileName, IO.File.ReadAllText(RichTextBox1.Text), "")
                    MsgBox("SourceCode Compiled Successfully.", MsgBoxStyle.Information, Title:="Information")
                End If
            End With
        End Sub
    End Class
    

    Et voici la class CodeDom Compiler:

    Imports System.CodeDom.Compiler
    Public Class CodeDomCompiler
    
        Public Shared Sub Compile(ByVal Output As String, ByVal Source As String, ByVal ICON As String)
            On Error Resume Next
    
            Dim cCompiler As ICodeCompiler = (New VBCodeProvider).CreateCompiler()
            Dim cCompileParams As New CompilerParameters()
            Dim cResults As CompilerResults
    
            cCompileParams.GenerateExecutable = True
            cCompileParams.OutputAssembly = Output
            cCompileParams.CompilerOptions = "/target:winexe"
            cCompileParams.ReferencedAssemblies.Add("System.dll")
            cCompileParams.ReferencedAssemblies.Add("System.Data.dll")
            cCompileParams.ReferencedAssemblies.Add("System.Windows.Forms.dll")
    
            Dim FASFASFFF = New Dictionary(Of String, String)
            FASFASFFF.Add("CompilerVersion", "v2.0")
    
            cCompileParams.CompilerOptions = "/filealign:0x00000200 /optimize+ /platform:X86 /target:winexe"
    
    
    
            cResults = cCompiler.CompileAssemblyFromSource(cCompileParams, Source)
    
            If cResults.Errors.Count > 0 Then
                For Each CompilerError In cResults.Errors
                    MessageBox.Show("Error: " & CompilerError.ErrorText, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Next
            ElseIf cResults.Errors.Count = 0 Then
    
            End If
        End Sub
    End Class

    Mercii.

    lundi 28 octobre 2013 23:00

Toutes les réponses