When I run the code the exception stated above stps the code with the following message:
An error occurred creating the form. The error is: Object variable or with block variable not set. Inner Exception
NullReferenceException:Object variable or with block variable not set.
This is the section of the ApplicationDesigner.vb where the exception is.
Code:
 <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Protected Overrides Sub OnCreateMainForm()
            Me.MainForm = Global.StringTest.PrintFrm       <<<<<<<<<
        End Sub
The line where it occurs is marked with chevrons.
Here is the form code:
Code:
Imports PdfSharp
Imports PdfSharp.Drawing
Imports PdfSharp.Fonts
Imports PdfSharp.PageOrientation
Imports PdfSharp.PageSize
Imports PdfSharp.Pdf
Imports PdfSharp.Internal
Imports PdfSharp.Drawing.Layout

Enum pageOrientation
    Landscape
    Portrait
End Enum
Enum Pagesize
    A4
    A5
End Enum
Public Class PrintFrm
    Private connectionString As String = "Data Source=DESKTOP-S7FRNAL\SQLEXPRESS;Initial Catalog=Verses_Find;Integrated Security=True"
    Public Property dt As Object
    Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
        MessageBox.Show(Replace(txbVerse.Text, Chr(13) & Chr(10), " VBCrLf "))
        Dim boxX As Integer
        Dim boxY As Integer
        Dim cellw As Integer
        Dim cellh As Integer
        Dim ort As String = Nothing
        Dim FSize As Integer
        Dim CFont As String = Nothing
        Dim TxtColorValue As String = Nothing

        Dim document As PdfDocument
        ' Create a new PDF document
        document = New PdfDocument()
        document.Info.Title = "Created with PDFsharp"

        ' Create an empty page
        Dim page As PdfPage = document.AddPage

        If ort = "L" Then
            page.Orientation = CType(pageOrientation.Landscape, PdfSharp.PageOrientation)
            page.Width = XUnit.FromMillimeter(297)
            page.Height = XUnit.FromMillimeter(210)
        Else
            page.Orientation = CType(pageOrientation.Portrait, PdfSharp.PageOrientation)
            page.Width = XUnit.FromMillimeter(210)
            page.Height = XUnit.FromMillimeter(297)
        End If



        ' Draw the text
        Dim Ftext As String = txbVerse.Text



        Dim gfx As XGraphics
        gfx = XGraphics.FromPdfPage(page)
        Dim font As XFont = New XFont(CFont, FSize, XFontStyle.Regular)
        Dim tf As XTextFormatter
        tf = New XTextFormatter(gfx)

        Dim rect As XRect
        rect = New XRect(boxX, boxY, cellw, cellh)
        gfx.DrawRectangle(XBrushes.SeaShell, rect)
        tf.Alignment = XParagraphAlignment.Center
        tf.DrawString(Ftext, font, XBrushes.Black, rect, XStringFormats.TopLeft)

        ' Save the document
        Dim filename As String = "verse.pdf"
        document.Save(filename)

        ' ...and start a viewer.
        Process.Start(filename)
    End Sub

    Private Sub btnPaste_Click(sender As Object, e As EventArgs) Handles btnPaste.Click

        ' Determine if there is any text in the Clipboard to paste into the text box.
        If Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) = True Then
            ' Determine if any text is selected in the text box.
            If txbVerse.SelectionLength > 0 Then
                ' Ask user if they want to paste over currently selected text.
                If MessageBox.Show("Do you want to paste over current selection?",
                    "Cut Example", MessageBoxButtons.YesNo) = DialogResult.No Then
                    ' Move selection to the point after the current selection and paste.
                    txbVerse.SelectionStart = txbVerse.SelectionStart +
                        txbVerse.SelectionLength
                End If
            End If
            ' Paste current text in Clipboard into text box.
            txbVerse.Paste()
        End If
    End Sub

    Private Sub PrnForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'ColorDataSet.TxtColor' table. You can move, or remove it, as needed.
        Me.TxtColorTableAdapter.Fill(Me.ColorDataSet.TxtColor)
        'TODO: This line of code loads data into the 'Verses_Find_Color_DataSet.TxtColor' table. You can move, or remove it, as needed.
        Me.CSizeTableAdapter.Fill(Me.Verses_FindDataSet.CSize)
        Dim Print As New PrintFrm
        Me.TopMost = True
        Me.WindowState = FormWindowState.Normal

        For Each oFont As FontFamily In FontFamily.Families 'This line populates the font combo with the system installed fonts
            cboFont.Items.Add(oFont.Name)
        Next

    End Sub

    Private Sub cboCSize_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCSize.SelectedIndexChanged
        Me.CSizeTableAdapter.Fill(Me.Verses_FindDataSet.CSize)
        Dim CSizeValue As Integer
        Dim cboCSize As Object = Nothing
        CSizeValue = cboCSize.selectedvalue
    End Sub

    Private Sub cboColor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboColor.SelectedIndexChanged
        Me.TxtColorTableAdapter.Fill(Me.ColorDataSet.TxtColor)
        Dim TxtColorValue As Integer
        Dim cboColor As Object = Nothing
        TxtColorValue = cboColor.selectedvalue
    End Sub

    Private Sub nudTop_ValueChanged(sender As Object, e As EventArgs)
        Dim Top As Integer
        Dim nudTop As Object = Nothing
        Top = nudTop.value
    End Sub

    Private Sub nudFSize_ValueChanged(sender As Object, e As EventArgs) Handles nudFSize.ValueChanged
        Dim FSize As Integer
        Dim nudFSize As Object = Nothing
        FSize = nudFSize.value


    End Sub

    Private Sub cboFont_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboFont.SelectedIndexChanged
        Dim CFont As String = cboFont.Text
    End Sub
End Class
Can someone help me correct this exception,as I can't run the code?