创建表单时出错。有关Visual Basic .NET中的详细信息,请参阅Exception.InnerException [英] An error occurred creating the form. See Exception.InnerException for details in Visual basic .NET

查看:129
本文介绍了创建表单时出错。有关Visual Basic .NET中的详细信息,请参阅Exception.InnerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在创建表单时遇到错误,这就是它所说的。我不知道该怎么做。有人可以帮忙吗?





谢谢,

iProgramIt



错误:

 System.InvalidOperationException未处理
HResult = -2146233079
消息=创建表单时出错。有关详细信息,请参阅Exception.InnerException。错误是:对象引用未设置为对象的实例。
来源=编码员的Digi-书
堆栈跟踪:在Coders_Digi_Book.My.MyProject.MyForms.Create__Instance __ [T](T实例)在17d14f5c-a337-4978-8281-53493378c1071.vb
: Coders_Digi_Book.My.MyProject.MyForms.get_Form1()
在Coders_Digi_Book.My.MyApplication.OnCreateMainForm()中的C:\ Users \ macc0017 \ Documents \ Visual Studio 2013中的190
\\Projects\Coders的Digi-Book\Coders的Digi-Book\My Project\Application.Designer.vb:行35
在Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
。在微软.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String [] commandLine)
at Coders_Digi_Book.My.MyApplication.Main(String [] Args)in 17d14f5c -a337-4978-8281-53493378c1071.vb:第81行
在System.AppDomain._nExecuteAssembly(RuntimeAssembly)组件,字串[] args)
。在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
。在System.Threading.ExecutionContext.RunInternal(的ExecutionContext的ExecutionContext,ContextCallback回调,对象的状态,布尔preserveSyncCtx)
。在System.Threading.ExecutionContext.Run(的ExecutionContext的ExecutionContext,ContextCallback回调,对象的状态,布尔preserveSyncCtx)
。在System.Threading.ExecutionContext.Run(的ExecutionContext的ExecutionContext,ContextCallback回调,对象状态)
。在System.Threading.ThreadHelper.ThreadStart()
InnerException:System.NullReferenceException
HResult = -2147467261
Message =对象引用未设置为对象的实例。
来源=编码员的Digi-书
堆栈跟踪:
。在Coders_Digi_Book.Form1.FastColoredTextBox1_TextChanged(对象发件人,TextChangedEventArgs e)在C:\Users\mac0017\Documents\Visual工作室2013 \Projects\Coders Digi-Book \ Code Digi-Book\Form1.vb:line 157
at System.EventHandler`1.Invoke(Object sender,TEventArgs e)
at FastColoredTextBoxNS.FastColoredTextBox .OnTextChanged(TextChangedEventArgs args)
at FastColoredTextBoxNS.FastColoredTextBox.OnTextChanged()
at FastColoredTextBoxNS.FastColoredTextBox.System.ComponentModel.ISupportInitialize.EndInit()
at C Coders_Digi_Book.Form1.InitializeComponent()in C :\ Users\mac0017 \Documents\Visual Studio 2013 \Projects\Coders Digi-Book \ Code Digi-Book\Form1.Designer.vb:360行
在Coders_Digi_Book.Form1 .. ctor()in C:\ Users \ macc0017 \ Documents\Visual Studio 2013 \Projects\Coders Digi-Book\Coders Digi-Book\Form1.vb:28行
InnerException:





表格的代码:

  Imports  System.ComponentModel 

公开 Form1
私有 Const WM_NCLBUTTONDOWN 作为 =& HA1
私有 Const WM_NCLBUTTONUP As =& HA0
私有 Const WM_MOVING 作为 =& H216
私人 Const WM_SIZE 作为 =& H5
受保护的 覆盖 Sub DefWndProc( ByRef m As System.Windows.Forms.Message)
静态 LButtonDown 作为 布尔
如果 CLng (m.Msg)= WM_NCLBUTTONDOWN 那么
LButtonDown = True
ElseIf CLng (m.Msg)= WM_NCLBUTTONUP 然后
LButtonDown = 错误
结束 如果
如果 LButtonDown 然后
如果 CLng ( m.Msg)= WM_MOVING 然后
如果 .Opacity<> 0 9 然后 Me .Opacity = 0 5
< span class =code-keyword> ElseIf CLng (m.Msg)= WM_SIZE 然后
如果 .Opacity<> 0 6 然后 Me .Opacity = 0 6
< span class =code-keyword>结束 如果
ElseIf LButtonDown 然后
如果 Me .Opacity<> 1 0 然后 Me .Opacity = 1 0
< span class =code-keyword>结束 如果
MyBase .DefWndProc (m)
结束 Sub
公共 SnippetsFolder 作为 字符串 = Application.StartupPath& \ Snippets \
公开 RelativeFolder As Boolean = IO.File.ReadAllLines(Application.StartupPath& \ Settingtings.cdbs)( 0
公开 AutoSave 作为 布尔 = IO.File.ReadAllLines(Application.StartupPath& \ Settings.cdbs)(< span class =code-digit> 2 )
私有 Sub MenuItem3_Click (发件人作为 对象,e 作为 EventArgs )句柄 MenuItem3.Click
FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.CSharp
End Sub
私有 Sub MenuItem4_Click(发件人 对象,e As EventArgs)句柄 MenuItem4.Click
FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.VB
结束 Sub
私有 Sub MenuItem5_Click(发件人作为 对象,e As EventArgs)句柄 MenuItem5.Click
FastColoredTextBox1.Language = FastCo loredTextBoxNS.Language.HTML
结束 Sub
私有 Sub MenuItem6_Click(发件人作为 对象,e As EventArgs)句柄 MenuItem6.Click
FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.XML
结束 Sub
私有 Sub MenuItem7_Click(发件人作为 对象,e As EventArgs)句柄 MenuItem7.Click
FastColoredTextBox1。 Language = FastColoredTextBoxNS.Language.SQL
结束 Sub
私有 Sub MenuItem8_Click (发件人作为 对象,e 作为 EventArgs )句柄 MenuItem8.Click
FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.PHP
结束 Sub
私有 Sub MenuItem9_Click(发件人作为 对象,e 作为 EventArgs)句柄 MenuItem9.Click
FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.JS
End Sub
Pri vate Sub MenuItem10_Click(发件人作为 对象,e As EventArgs)句柄 MenuItem10.Click
FastColoredTextBox1.Language = FastColoredTextBoxNS。 Language.Lua
结束 Sub
私人 Sub Form1_Load(发件人作为 对象,e As EventArgs)句柄 MyBase .Load
' 这会进入事件代码
如果 .IsInitializing = True 然后
退出 Sub
其他
' 地点此处事件的代码
结束 如果
Dim lsc As launchScreenControl
< span class =code-keyword> Me .Controls.Add(lsc)
lsc.Dock = DockStyle.Fill
lsc.BringToFront()
If RelativeFolder = False 然后
SnippetsFolder = IO。 File.ReadAllLines(Application.StartupPath& \ Settingtings.cdbs)( 1 )& \
其他:SnippetsFolder = Application.StartupPath& \ Snippets \
End 如果
RebuildSnippetList()
结束 Sub
私有 Sub MenuItem11_Click(发件人作为 对象,e As EventArgs)句柄 MenuItem11.Click
NewSnippet()
结束 Sub
Sub NewSnippet()
IO.File.WriteAllText(SnippetsFolder& InputBox( 请为该片段命名:)& 。CDBF
RebuildSnippetList()
结束 Sub
Sub RebuildSnippetList()
Dim MyImages 作为 ImageList()
MyImages.ColorDepth = ColorDepth.Depth32Bit
MyImages.ImageSize = 大小( 16 16
MyImages.Images.Add( Folder,My.Resources.winvista_ico_shell32_dll_003)
MyImages.Images.Add( Item,My.Resources.winvista_ico_shell32_dll_071)
TreeView1.ImageList = MyImages
TreeView1.Nodes.Clear()
如果 IO.Directory.Exists(SnippetsFolder)= False 然后 IO.Directory.CreateDirectory(SnippetsFolder)
Dim i As 整数 = 0
对于 每个文件夹作为 字符串 IO.Directory.GetDirectories(SnippetsFolder)
TreeView1.Nodes.Add( Folder,My.Computer.FileSystem.GetName(Folder))
对于 每个文件作为 字符串 在< /温泉n> IO.Directory.GetFiles(Folder, * .cdbf
Dim specFile As String = My.Computer.FileSystem .GetName(File)
Dim specIndex As 整数 = specFile.LastIndexOf(
TreeView1.Nodes( i).Nodes.Add( Item,specFile.Remove(specIndex), 1 1
下一步
i + = 1
下一步
' Lis tBox1.Items.Clear()
' 如果IO.Directory.Exists(SnippetsFolder)=错误然后IO.Directory.CreateDirectory(SnippetsFolder)
' 对于每个文件作为字符串在IO中.Directory.GetFiles(SnippetsFolder,* .cdbf)
' Dim specFile As String = My.Computer.FileSystem.GetName(file)
' Dim specIndex As Integer = specFile .LastIndexOf(。)
' ListBox1.Items.Add(specFile.Remove( specIndex))
' 下一步
结束 Sub
私人 Sub MenuItem17_Click(发件人作为 对象 ,e As EventArgs)句柄 MenuItem17.Click
.Close()
结束 Sub
私有 Sub NewToolStripButton_Click(发件人 As 对象,e As EventArgs)句柄 NewToolStripButton.Click
NewSnippet()
结束 Sub
私有 Sub CutToolStripButton_Click(发件人作为 Object ,e As EventArgs) Handles CutToolStripButton.Click
FastColoredTextBox1.Cut()
结束 Sub
私有 Sub CopyToolStripButton_Click(发件人作为 对象,e As EventArgs)句柄 CopyToolStripButton.Click
FastColoredTextBox1。复制()
结束 Sub
私人 Sub PasteToolStripButton_Click(发件人作为 对象,e As EventArgs)句柄 PasteToolStripButton.Click
FastColoredTextBox1.Paste()
结束 Sub
Sub SingleImport()
Dim ofd 正如 OpenFileDialog
ofd.Filter = Coders'Digi-Book Files(* .cdbf)| * .cdbf
ofd.Title = Import Snippet ..
如果 ofd.ShowDialog = Windows.Forms.DialogResult.OK 然后
如果 IO.Directory.Exists(SnippetsFolder& \Imported \)= False 然后 IO.Directory.CreateDirectory(SnippetsFolder& \Imported \
IO.File.Copy(ofd.FileName,SnippetsFolder& \Imported \& My.Computer.FileSystem.GetName(ofd.FileName))
RebuildSnippetList()
结束 如果
结束 Sub
私有 Sub OpenToolStripButton_Click(发件人作为 对象,e As EventArgs)句柄 OpenToolStripButton.Click
SingleImport()
结束 Sub
私有 Sub MenuItem12_Click(发件人 As 对象,e As EventArgs)句柄 MenuItem12.Click
SingleImport()
结束 Sub
Sub SingleExport()
如果 TreeView1.SelectedNode.SelectedImageIndex = 1 然后
Dim sfd As SaveFileDialog
sfd.Filter = 编码器的Digi-Book文件(* .cdbf)| * .cdbf
sfd.Title = Export Snippet ..
如果 sfd .ShowDialog = Windows.Forms.DialogResult.OK 然后
IO.File.Copy(SnippetsFolder& \& TreeView1.SelectedNode.Parent.Text& \& TreeView1.SelectedNode.Text& 。cdbf,sfd.FileName)
结束 如果
结束 如果
结束 Sub
私有 Sub MenuItem14_Click(发件人作为 对象,e As EventArgs)句柄 MenuItem14.Click
SingleExport()
结束 Sub
私有 Sub SaveToolStripButton_Click(发件人作为 对象,e As EventArgs)句柄 SaveToolStripButton.Click
如果 TreeView1.SelectedNode.SelectedImageIndex = < span class =code-digit> 1
然后
IO.File.WriteAllText(SnippetsFolder& \& TreeView1.SelectedNode.Parent.Text& \& TreeView1.SelectedNode.Text& 。cdbf,FastColoredTextBox1.Text)
结束 如果
结束 Sub
私有 Sub ListBox1_SelectedIndexChanged(sender 作为 对象,e As EventArgs)句柄 ListBox1.SelectedIndexChanged
FastColoredTextBox1.Text = IO.File.ReadAllText(SnippetsFolder& ListBox1.SelectedItem& 。cdbf
结束 Sub
私有 Sub FastColoredTextBox1_TextChanged(sender As Object ,e As FastColoredTextBoxNS.TextChangedEventArgs) 句柄 FastColoredTextBox1.TextChanged
如果 TreeView1.SelectedNode.ImageIndex = 1 然后
如果 AutoSave 然后 IO.File.WriteAllText(SnippetsFolder& \& TreeView1.SelectedNode.Parent.Text& \& TreeView1.SelectedNode.Text& 。cdbf,FastColoredTextBox1.Text)
结束 如果
结束 Sub
私有 Sub MenuItem20_Click(发件人作为 对象,e As EventArgs)句柄 MenuItem20.Click
RebuildSnippetList()
结束 Sub
私有 Sub HelpToolStripButton_Click(发件人 As 对象,e As EventArgs)句柄 HelpToolStrip Button.Click
Dim frm As New 设置
如果 frm.ShowDialog = Windows.Forms.DialogResult.OK 那么
Dim lbl 作为 标签
lbl.Text = 已对设置进行了更改。单击此文本以重新启动。
lbl.AutoSize = False
lbl.Font = 字体( Arial 12
lbl.Dock = DockStyle.Fill
AddHandler (lbl.Click), AddressOf ClickTheLabel
Me .Controls.Add(lbl)
lbl.BringToFront()
ToolStrip1。已启用= 错误
对于 每个 mnuItem 作为 MenuItem MainMenu1.MenuItems
mnuItem.Enabled = 错误
下一步
结束 如果
结束 < span class =code-keyword> Sub
Sub ClickTheLabel(sender As 对象,e As EventArgs)
Application.Restart()
结束 Sub
私有 Sub Form1_Resize(发件人作为 对象,e As EventArgs)句柄 .Resize
结束 Sub
私人 < span class =code-keyword> Sub MenuItem13_Click(sen der 作为 对象,e As EventArgs) 句柄 MenuItem13.Click
Dim FOLDERDG As New FolderBrowserDialog
FOLDERDG.ShowNewFolderButton = False
FOLDERDG.Description = \"Please select a folder to retrieve the snippets from.\"
If FOLDERDG.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each file As String In IO.Directory.GetFiles(FOLDERDG.SelectedPath, \"*.cdbf\")
IO.File.Copy(file, SnippetsFolder & \"\Imported\\" & My.Computer.FileSystem.GetName(file))
Next
End If
RebuildSnippetList()
End Sub
Private Sub MenuItem21_Click(sender As Object, e As EventArgs) Handles MenuItem21.Click
Dim FOLDERDG As New FolderBrowserDialog
FOLDERDG.ShowNewFolderButton = False
FOLDERDG.Description = \"Please select a folder to copy the snippets to.\"
If FOLDERDG.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each file As String In IO.Directory.GetFiles(SnippetsFolder, \"*.cdbf\")
IO.File.Copy(file, FOLDERDG.SelectedPath & My.Computer.FileSystem.GetName(file))
Next
End If
End Sub
Private Sub MenuItem23_Click(sender As Object, e As EventArgs) Handles MenuItem23.Click
Dim cde As New codingEnvironment
cde.Show()
End Sub
Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
If TreeView1.SelectedNode.SelectedImageIndex = 1 Then
FastColoredTextBox1.Enabled = True
FastColoredTextBox1.Text = IO.File.ReadAllText(SnippetsFolder & \& e.Node.Parent.Text & \& e.Node.Text & \".cdbf\")
Else
FastColoredTextBox1.Enabled = False
FastColoredTextBox1.Text = \"\"
End If
End Sub
Private Sub FastColoredTextBox1_Load(sender As Object, e As EventArgs) Handles FastColoredTextBox1.Load

End Sub
End Class

解决方案

Does the file \"Settings.cdbs\" definitely exist in the application folder? (Remember this will be in bin\Debug or bin\Release when you build your app from the IDE)



If not, select the file in the IDE and in the properties pane set \"Copy to output\" property to \"Always\".


Hi guys,
I have an error when creating my form, and this is what it says. I have no idea what to do. Could someone help?


Thanks,
iProgramIt

The error:

System.InvalidOperationException was unhandled
  HResult=-2146233079
  Message=An error occurred creating the form. See Exception.InnerException for details.  The error is: Object reference not set to an instance of an object.
  Source=Coders Digi-Book
  StackTrace:
       at Coders_Digi_Book.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
       at Coders_Digi_Book.My.MyProject.MyForms.get_Form1()
       at Coders_Digi_Book.My.MyApplication.OnCreateMainForm() in C:\Users\mac0017\Documents\Visual Studio 2013\Projects\Coders Digi-Book\Coders Digi-Book\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 Coders_Digi_Book.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.NullReferenceException
       HResult=-2147467261
       Message=Object reference not set to an instance of an object.
       Source=Coders Digi-Book
       StackTrace:
            at Coders_Digi_Book.Form1.FastColoredTextBox1_TextChanged(Object sender, TextChangedEventArgs e) in C:\Users\mac0017\Documents\Visual Studio 2013\Projects\Coders Digi-Book\Coders Digi-Book\Form1.vb:line 157
            at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
            at FastColoredTextBoxNS.FastColoredTextBox.OnTextChanged(TextChangedEventArgs args)
            at FastColoredTextBoxNS.FastColoredTextBox.OnTextChanged()
            at FastColoredTextBoxNS.FastColoredTextBox.System.ComponentModel.ISupportInitialize.EndInit()
            at Coders_Digi_Book.Form1.InitializeComponent() in C:\Users\mac0017\Documents\Visual Studio 2013\Projects\Coders Digi-Book\Coders Digi-Book\Form1.Designer.vb:line 360
            at Coders_Digi_Book.Form1..ctor() in C:\Users\mac0017\Documents\Visual Studio 2013\Projects\Coders Digi-Book\Coders Digi-Book\Form1.vb:line 28
       InnerException: 



The Form's code:

Imports System.ComponentModel

Public Class Form1
    Private Const WM_NCLBUTTONDOWN As Long = &HA1
    Private Const WM_NCLBUTTONUP As Long = &HA0
    Private Const WM_MOVING As Long = &H216
    Private Const WM_SIZE As Long = &H5
    Protected Overrides Sub DefWndProc(ByRef m As System.Windows.Forms.Message)
        Static LButtonDown As Boolean
        If CLng(m.Msg) = WM_NCLBUTTONDOWN Then
            LButtonDown = True
        ElseIf CLng(m.Msg) = WM_NCLBUTTONUP Then
            LButtonDown = False
        End If
        If LButtonDown Then
            If CLng(m.Msg) = WM_MOVING Then
                If Me.Opacity <> 0.9 Then Me.Opacity = 0.5
            ElseIf CLng(m.Msg) = WM_SIZE Then
                If Me.Opacity <> 0.6 Then Me.Opacity = 0.6
            End If
        ElseIf Not LButtonDown Then
            If Me.Opacity <> 1.0 Then Me.Opacity = 1.0
        End If
        MyBase.DefWndProc(m)
    End Sub
    Public SnippetsFolder As String = Application.StartupPath & "\Snippets\"
    Public RelativeFolder As Boolean = IO.File.ReadAllLines(Application.StartupPath & "\Settings.cdbs")(0)
    Public AutoSave As Boolean = IO.File.ReadAllLines(Application.StartupPath & "\Settings.cdbs")(2)
    Private Sub MenuItem3_Click(sender As Object, e As EventArgs) Handles MenuItem3.Click
        FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.CSharp
    End Sub
    Private Sub MenuItem4_Click(sender As Object, e As EventArgs) Handles MenuItem4.Click
        FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.VB
    End Sub
    Private Sub MenuItem5_Click(sender As Object, e As EventArgs) Handles MenuItem5.Click
        FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.HTML
    End Sub
    Private Sub MenuItem6_Click(sender As Object, e As EventArgs) Handles MenuItem6.Click
        FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.XML
    End Sub
    Private Sub MenuItem7_Click(sender As Object, e As EventArgs) Handles MenuItem7.Click
        FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.SQL
    End Sub
    Private Sub MenuItem8_Click(sender As Object, e As EventArgs) Handles MenuItem8.Click
        FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.PHP
    End Sub
    Private Sub MenuItem9_Click(sender As Object, e As EventArgs) Handles MenuItem9.Click
        FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.JS
    End Sub
    Private Sub MenuItem10_Click(sender As Object, e As EventArgs) Handles MenuItem10.Click
        FastColoredTextBox1.Language = FastColoredTextBoxNS.Language.Lua
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'this goes into the event code  
        If Me.IsInitializing = True Then
            Exit Sub
        Else
            'place the code for the event here  
        End If
        Dim lsc As New launchScreenControl
        Me.Controls.Add(lsc)
        lsc.Dock = DockStyle.Fill
        lsc.BringToFront()
        If RelativeFolder = False Then
            SnippetsFolder = IO.File.ReadAllLines(Application.StartupPath & "\Settings.cdbs")(1) & "\"
        Else : SnippetsFolder = Application.StartupPath & "\Snippets\"
        End If
        RebuildSnippetList()
    End Sub
    Private Sub MenuItem11_Click(sender As Object, e As EventArgs) Handles MenuItem11.Click
        NewSnippet()
    End Sub
    Sub NewSnippet()
        IO.File.WriteAllText(SnippetsFolder & InputBox("Please name the snippet:") & ".cdbf", "")
        RebuildSnippetList()
    End Sub
    Sub RebuildSnippetList()
        Dim MyImages As New ImageList()
        MyImages.ColorDepth = ColorDepth.Depth32Bit
        MyImages.ImageSize = New Size(16, 16)
        MyImages.Images.Add("Folder", My.Resources.winvista_ico_shell32_dll_003)
        MyImages.Images.Add("Item", My.Resources.winvista_ico_shell32_dll_071)
        TreeView1.ImageList = MyImages
        TreeView1.Nodes.Clear()
        If IO.Directory.Exists(SnippetsFolder) = False Then IO.Directory.CreateDirectory(SnippetsFolder)
        Dim i As Integer = 0
        For Each Folder As String In IO.Directory.GetDirectories(SnippetsFolder)
            TreeView1.Nodes.Add("Folder", My.Computer.FileSystem.GetName(Folder))
            For Each File As String In IO.Directory.GetFiles(Folder, "*.cdbf")
                Dim specFile As String = My.Computer.FileSystem.GetName(File)
                Dim specIndex As Integer = specFile.LastIndexOf(".")
                TreeView1.Nodes(i).Nodes.Add("Item", specFile.Remove(specIndex), 1, 1)
            Next
            i += 1
        Next
        'ListBox1.Items.Clear()
        'If IO.Directory.Exists(SnippetsFolder) = False Then IO.Directory.CreateDirectory(SnippetsFolder)
        'For Each file As String In IO.Directory.GetFiles(SnippetsFolder, "*.cdbf")
        '    Dim specFile As String = My.Computer.FileSystem.GetName(file)
        '    Dim specIndex As Integer = specFile.LastIndexOf(".")
        '    ListBox1.Items.Add(specFile.Remove(specIndex))
        'Next
    End Sub
    Private Sub MenuItem17_Click(sender As Object, e As EventArgs) Handles MenuItem17.Click
        Me.Close()
    End Sub
    Private Sub NewToolStripButton_Click(sender As Object, e As EventArgs) Handles NewToolStripButton.Click
        NewSnippet()
    End Sub
    Private Sub CutToolStripButton_Click(sender As Object, e As EventArgs) Handles CutToolStripButton.Click
        FastColoredTextBox1.Cut()
    End Sub
    Private Sub CopyToolStripButton_Click(sender As Object, e As EventArgs) Handles CopyToolStripButton.Click
        FastColoredTextBox1.Copy()
    End Sub
    Private Sub PasteToolStripButton_Click(sender As Object, e As EventArgs) Handles PasteToolStripButton.Click
        FastColoredTextBox1.Paste()
    End Sub
    Sub SingleImport()
        Dim ofd As New OpenFileDialog
        ofd.Filter = "Coders' Digi-Book Files (*.cdbf)|*.cdbf"
        ofd.Title = "Import Snippet.."
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
            If IO.Directory.Exists(SnippetsFolder & "\Imported\") = False Then IO.Directory.CreateDirectory(SnippetsFolder & "\Imported\")
            IO.File.Copy(ofd.FileName, SnippetsFolder & "\Imported\" & My.Computer.FileSystem.GetName(ofd.FileName))
            RebuildSnippetList()
        End If
    End Sub
    Private Sub OpenToolStripButton_Click(sender As Object, e As EventArgs) Handles OpenToolStripButton.Click
        SingleImport()
    End Sub
    Private Sub MenuItem12_Click(sender As Object, e As EventArgs) Handles MenuItem12.Click
        SingleImport()
    End Sub
    Sub SingleExport()
        If TreeView1.SelectedNode.SelectedImageIndex = 1 Then
            Dim sfd As New SaveFileDialog
            sfd.Filter = "Coders' Digi-Book Files (*.cdbf)|*.cdbf"
            sfd.Title = "Export Snippet.."
            If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
                IO.File.Copy(SnippetsFolder & "\" & TreeView1.SelectedNode.Parent.Text & "\" & TreeView1.SelectedNode.Text & ".cdbf", sfd.FileName)
            End If
        End If
    End Sub
    Private Sub MenuItem14_Click(sender As Object, e As EventArgs) Handles MenuItem14.Click
        SingleExport()
    End Sub
    Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
        If TreeView1.SelectedNode.SelectedImageIndex = 1 Then
            IO.File.WriteAllText(SnippetsFolder & "\" & TreeView1.SelectedNode.Parent.Text & "\" & TreeView1.SelectedNode.Text & ".cdbf", FastColoredTextBox1.Text)
        End If
    End Sub
    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        FastColoredTextBox1.Text = IO.File.ReadAllText(SnippetsFolder & ListBox1.SelectedItem & ".cdbf")
    End Sub
    Private Sub FastColoredTextBox1_TextChanged(sender As Object, e As FastColoredTextBoxNS.TextChangedEventArgs) Handles FastColoredTextBox1.TextChanged
        If TreeView1.SelectedNode.ImageIndex = 1 Then
            If AutoSave Then IO.File.WriteAllText(SnippetsFolder & "\" & TreeView1.SelectedNode.Parent.Text & "\" & TreeView1.SelectedNode.Text & ".cdbf", FastColoredTextBox1.Text)
        End If
    End Sub
    Private Sub MenuItem20_Click(sender As Object, e As EventArgs) Handles MenuItem20.Click
        RebuildSnippetList()
    End Sub
    Private Sub HelpToolStripButton_Click(sender As Object, e As EventArgs) Handles HelpToolStripButton.Click
        Dim frm As New Settings
        If frm.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim lbl As New Label
            lbl.Text = "Changes have been made to settings. Click this text to restart."
            lbl.AutoSize = False
            lbl.Font = New Font("Arial", 12)
            lbl.Dock = DockStyle.Fill
            AddHandler (lbl.Click), AddressOf ClickTheLabel
            Me.Controls.Add(lbl)
            lbl.BringToFront()
            ToolStrip1.Enabled = False
            For Each mnuItem As MenuItem In MainMenu1.MenuItems
                mnuItem.Enabled = False
            Next
        End If
    End Sub
    Sub ClickTheLabel(sender As Object, e As EventArgs)
        Application.Restart()
    End Sub
    Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
    End Sub
    Private Sub MenuItem13_Click(sender As Object, e As EventArgs) Handles MenuItem13.Click
        Dim FOLDERDG As New FolderBrowserDialog
        FOLDERDG.ShowNewFolderButton = False
        FOLDERDG.Description = "Please select a folder to retrieve the snippets from."
        If FOLDERDG.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each file As String In IO.Directory.GetFiles(FOLDERDG.SelectedPath, "*.cdbf")
                IO.File.Copy(file, SnippetsFolder & "\Imported\" & My.Computer.FileSystem.GetName(file))
            Next
        End If
        RebuildSnippetList()
    End Sub
    Private Sub MenuItem21_Click(sender As Object, e As EventArgs) Handles MenuItem21.Click
        Dim FOLDERDG As New FolderBrowserDialog
        FOLDERDG.ShowNewFolderButton = False
        FOLDERDG.Description = "Please select a folder to copy the snippets to."
        If FOLDERDG.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each file As String In IO.Directory.GetFiles(SnippetsFolder, "*.cdbf")
                IO.File.Copy(file, FOLDERDG.SelectedPath & My.Computer.FileSystem.GetName(file))
            Next
        End If
    End Sub
    Private Sub MenuItem23_Click(sender As Object, e As EventArgs) Handles MenuItem23.Click
        Dim cde As New codingEnvironment
        cde.Show()
    End Sub
    Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
        If TreeView1.SelectedNode.SelectedImageIndex = 1 Then
            FastColoredTextBox1.Enabled = True
            FastColoredTextBox1.Text = IO.File.ReadAllText(SnippetsFolder & "\" & e.Node.Parent.Text & "\" & e.Node.Text & ".cdbf")
        Else
            FastColoredTextBox1.Enabled = False
            FastColoredTextBox1.Text = ""
        End If
    End Sub
    Private Sub FastColoredTextBox1_Load(sender As Object, e As EventArgs) Handles FastColoredTextBox1.Load

    End Sub
End Class

解决方案

Does the file "Settings.cdbs" definitely exist in the application folder? (Remember this will be in bin\Debug or bin\Release when you build your app from the IDE)

If not, select the file in the IDE and in the properties pane set "Copy to output" property to "Always".


这篇关于创建表单时出错。有关Visual Basic .NET中的详细信息,请参阅Exception.InnerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆