本文介绍了如何在Visual Basic中修复此代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一段代码,我用CodeDOM编译。但是,当我执行程序时,它只是说程序已经停止工作......。
我该如何解决这个问题? CodeDOM程序中的代码如下:
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
提前致谢,
iProgramIt
Thanks in advance,
iProgramIt
推荐答案
这篇关于如何在Visual Basic中修复此代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!