locked
obsolete codedom compiler new method of compiler RRS feed

  • Question

  • can anyone help with a new method please
    Imports System.CodeDom.Compiler
    Public Class iCompiler
      Public Shared Sub GenerateExecutable(ByVal Output As String, ByVal Source As String, ByVal Icon As String)
        On Error Resume Next
    
        Dim Compiler As ICodeCompiler = (New VBCodeProvider).CreateCompiler()
        Dim Parameters As New CompilerParameters()
        Dim cResults As CompilerResults
    
        Parameters.GenerateExecutable = True
        Parameters.OutputAssembly = Output
        Parameters.ReferencedAssemblies.Add("System.dll")
        Parameters.ReferencedAssemblies.Add("System.Data.dll")
        Parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")
    
        Dim Version = New Dictionary(Of String, String)
        Version.Add("CompilerVersion", "v2.0")
    
        Dim ICO As String = IO.Path.GetTempPath & "\iCompiler.ico"
    Thursday, November 11, 2010 11:51 AM

Answers

All replies

  • Change the bold line below, that is from .net 1.1

     Dim Compiler As ICodeCompiler = (New VBCodeProvider).CreateCompiler()
     
     'to
     
      Dim Compiler As VBCodeProvider = New VBCodeProvider
     
      or to this in .net3.5 above
      Dim Compiler As System.CodeDom.Compiler.CodeDomProvider = Nothing
      Compiler = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("VisualBasic")
     

    kaymaf


    CODE CONVERTER SITE

    http://www.carlosag.net/Tools/CodeTranslator/.

    http://www.developerfusion.com/tools/convert/csharp-to-vb/.

    Thursday, November 11, 2010 2:15 PM
  • ty for your help very helpful
    Thursday, November 11, 2010 3:02 PM
  • sorry to bother you but your help regarding my project worked but threw another exeption on running this is what it says ...

           at WindowsApplication1.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
           at WindowsApplication1.My.MyProject.MyForms.get_Form1()
           at WindowsApplication1.My.MyApplication.OnCreateMainForm() in D:\vb\CodeDom_Crypter\CodeDom Crypter\CodeDom Crypter\My Project\Application.Designer.vb:line 35
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
           at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.IO.IOException
           Message="Could not complete operation since a file already exists in this path 'D:\\vb\\CodeDom_Crypter\\CodeDom Crypter\\CodeDom Crypter\\bin\\Debug\\stub.exe'."
           Source="Microsoft.VisualBasic"
           StackTrace:
                at Microsoft.VisualBasic.Devices.Network.DownloadFile(Uri address, String destinationFileName, ICredentials networkCredentials, Boolean showUI, Int32 connectionTimeout, Boolean overwrite, UICancelOption onUserCancel)
                at Microsoft.VisualBasic.Devices.Network.DownloadFile(String address, String destinationFileName, String userName, String password, Boolean showUI, Int32 connectionTimeout, Boolean overwrite, UICancelOption onUserCancel)
                at Microsoft.VisualBasic.Devices.Network.DownloadFile(String address, String destinationFileName, String userName, String password, Boolean showUI, Int32 connectionTimeout, Boolean overwrite)
                at Microsoft.VisualBasic.Devices.Network.DownloadFile(String address, String destinationFileName)
                at WindowsApplication1.Form1.InitializeComponent() in D:\vb\CodeDom_Crypter\CodeDom Crypter\CodeDom Crypter\Form1.Designer.vb:line 30
                at WindowsApplication1.Form1..ctor()
           InnerException:

     

    Friday, November 12, 2010 10:24 AM
  • Well, i cant tell what cause the error because i dont have your code. This may due to error in the code you want to compile at runtime or your program itself. What i can tell you from the error message you posted is that, check the lines that thrown errors as indicates below

    vb:line 81
    vb:line 190
    D:\vb\CodeDom_Crypter\CodeDom Crypter\CodeDom Crypter\My Project\Application.Designer.vb:line 35
    D:\vb\CodeDom_Crypter\CodeDom Crypter\CodeDom Crypter\Form1.Designer.vb:line 30

    By the way, 1 question per thread, so it will better if you can create another thread for this issue as original question was already solved.

    kaymaf


    CODE CONVERTER SITE

    http://www.carlosag.net/Tools/CodeTranslator/.

    http://www.developerfusion.com/tools/convert/csharp-to-vb/.

    Friday, November 12, 2010 2:25 PM