0 Replies - 449 Views - Last Post: 01 October 2015 - 12:32 AM Rate Topic: -----

#1 iProgramIt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-July 15

How do I fix this code in Visual Basic and CodeDOM?

Posted 01 October 2015 - 12:32 AM

Hi guys,
I have a piece of code, which I am compiling with CodeDOM. However, when I execute the program, it just says "The program has stopped working..".
How can I fix this? The code in the CodeDOM program is here:
Option Strict On
Imports System
Imports System.Windows.Forms
Imports System.Windows.Forms.Form
Imports System.Drawing
Imports Microsoft.VisualBasic
 
Public Class EntryPoint
    Public Shared Sub Main(args() As String)
        Dim FrmMain As New MainForm
        System.Windows.Forms.Application.Run(FrmMain)
    End Sub
End Class
Public Class MainForm
    Inherits System.Windows.Forms.Form
    Private WithEvents EventWB As New WebBrowser
    Sub New()
        Application.EnableVisualStyles()
        Me.Text = My.Resources.Addresser
        EventWB.Dock = DockStyle.Fill
        EventWB.Navigate(My.Resources.Addresser)
        Me.Controls.Add(EventWB)
        Me.Size = New Size(640, 480)
    End Sub
End Class
Namespace My.Resources
 
    '''<summary>
    '''  A strongly-typed resource class, for looking up localized strings, etc.
    '''</summary>
    <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
     Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
     Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
     Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
    Friend Module Resources
 
        Private resourceMan As Global.System.Resources.ResourceManager
 
        Private resourceCulture As Global.System.Globalization.CultureInfo
 
        '''<summary>
        '''  Returns the cached ResourceManager instance used by this class.
        '''</summary>
        <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
        Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
            Get
                If Object.ReferenceEquals(resourceMan, Nothing) Then
                    Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("WindowsApplication1.Resources", GetType(Resources).Assembly)
                    resourceMan = temp
                End If
                Return resourceMan
            End Get
        End Property
 
        '''<summary>
        '''  Overrides the current thread's CurrentUICulture property for all
        '''  resource lookups using this strongly typed resource class.
        '''</summary>
        <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
        Friend Property Culture() As Global.System.Globalization.CultureInfo
            Get
                Return resourceCulture
            End Get
            Set(value As Global.System.Globalization.CultureInfo)
                resourceCulture = value
            End Set
        End Property
 
        '''<summary>
        '''  Looks up a localized string similar to Blah.
        '''</summary>
        Friend ReadOnly Property Addresser() As String
            Get
                Return ResourceManager.GetString("Addresser", resourceCulture)
            End Get
        End Property
    End Module
End Namespace


The code I use to compile it is here:
Dim cp As CompilerParameters = New CompilerParameters()
        cp.ReferencedAssemblies.Add("System.dll")
        cp.ReferencedAssemblies.Add("System.Windows.Forms.dll")
        cp.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll")
        cp.ReferencedAssemblies.Add("System.Drawing.dll")
        cp.ReferencedAssemblies.Add("System.Core.dll")
        cp.ReferencedAssemblies.Add("mscorlib.dll")
        Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")
        cp.GenerateExecutable = True
        cp.OutputAssembly = "C:\Okay.exe"
        cp.MainClass = "EntryPoint"
        Using res As New ResourceWriter(Application.LocalUserAppDataPath & "\resources.resources")
            res.AddResource("Addresser", TextBox1.Text)
            res.Generate()
            res.Close()
        End Using
        cp.EmbeddedResources.Add(Application.LocalUserAppDataPath & "\resources.resources")
        cp.CompilerOptions = "/target:winexe"
        Dim errors As System.CodeDom.Compiler.CompilerResults = provider.CompileAssemblyFromSource(cp, My.Resources.Executioner)
        If errors.Errors.HasErrors Then
            MessageBox.Show(errors.Errors(0).ToString)
        End If

Also, the program that stops working is: Attached File  Okay.zip (3.79K)
Number of downloads: 12
Thanks in advance,
iProgramIt

Is This A Good Question/Topic? 0
  • +

Page 1 of 1