Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
VB
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:
VB
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


Thanks in advance,
iProgramIt
Posted

1 solution

We can't tell. We can't run your program, and don't have access to your data if we could!
So start by running it in the debugger - put an entry point at the start of the forms New method, and step your program through. Look carefully at each line before you execute it, and work out exactly what it should do. Then see if it does exactly that. If not, why not?

Sorry - but we can't do anything for you until you have at least some data as to where in your app it is "going wrong" and some idea of what it should be doing instead!
 
Share this answer
 
Comments
iProgramIt 1-Oct-15 3:28am    
Isn't that why I submitted the code as well? Could you maybe look over it? It doesn't use the debugger - I cannot hook it up. So I can't look it through line by line, unfortunately.
OriginalGriff 1-Oct-15 3:40am    
As I said: "We can't run your program, and don't have access to your data if we could!"

Only you can do this: it's a skill called debugging, and it's one that is developed by use. It's a lot easier to develop it working on little projects like this than trying on "real world" projects!
iProgramIt 1-Oct-15 4:15am    
I'm not stupid. I know what debugging is and I cannot test this in Visual Studio because it is an external program (the "CodeDOM program")
Patrice T 1-Oct-15 4:25am    
It is always possible to run a debugger on an external program ! that's a fact.
It is even possible to run the debugger on windows service programs.
Patrice T 1-Oct-15 4:21am    
It is always possible to run a debugger or trace a program.
Even without debugger, you can change the program in order to make it tell what part is run and what part is not.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900