Click here to Skip to main content
15,886,963 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: External process stops everything else Pin
piul14-Feb-11 2:25
piul14-Feb-11 2:25 
GeneralRe: External process stops everything else Pin
Luc Pattyn14-Feb-11 2:37
sitebuilderLuc Pattyn14-Feb-11 2:37 
GeneralRe: External process stops everything else Pin
piul14-Feb-11 4:34
piul14-Feb-11 4:34 
AnswerRe: External process stops everything else Pin
Luc Pattyn14-Feb-11 4:43
sitebuilderLuc Pattyn14-Feb-11 4:43 
GeneralRe: External process stops everything else Pin
piul14-Feb-11 5:08
piul14-Feb-11 5:08 
GeneralRe: External process stops everything else Pin
Luc Pattyn14-Feb-11 5:51
sitebuilderLuc Pattyn14-Feb-11 5:51 
GeneralRe: External process stops everything else Pin
piul14-Feb-11 5:59
piul14-Feb-11 5:59 
QuestionInfinite recursion wont go away. Pin
Herboren13-Feb-11 13:27
Herboren13-Feb-11 13:27 
I have 2 classes both of which are not trying to call a userform but I keep getting this error:
<br />
An error occurred creating the form. See Exception.InnerException for details.  The error is: The form referred to itself during construction from a default instance, which led to infinite recursion.  Within the Form's constructor refer to the form using 'Me.'<br />


This is the code to my form1:
Public Class Form1
    Dim getwmi As New wmiget()
    Dim smtp As New smtp()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        getwmi.Main()
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tbAt.Clear()
        FindAttachment.Title = "Please select a file"
        FindAttachment.InitialDirectory = Environment.GetEnvironmentVariable("userprofile") + "\Desktop"
        FindAttachment.ShowDialog()

    End Sub

    Private Sub FindAttachment_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles FindAttachment.FileOk
        Dim filepath As System.IO.FileStream = FindAttachment.OpenFile()
        tbAt.Text = FindAttachment.FileName.ToString.ToLower()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        tbTo.Clear()
        tbFr.Clear()
        tbSu.Clear()
        tbBo.Clear()
        tbSe.Clear()
        tbAt.Clear()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If tbUs.Text = "" And tbPa.Text = "" Then
            MsgBox("Smtp:[" + tbSe.Text + "]: requires a username and password to continue")
        End If
        smtp.smtp()
    End Sub
End Class

This is the code to my smtp class:
Imports System.Net.Mail
Public Class smtp

    Dim username As String = Form1.tbUs.Text
    Dim password As String = Form1.tbPa.Text

    Public Sub smtp()
        Try
            'Start by creating a mail message object
            Dim MyMailMessage As New MailMessage()

            'From requires an instance of the MailAddress type
            MyMailMessage.From = New MailAddress(Form1.tbFr.Text.ToLower())

            'To is a collection of MailAddress types 
            MyMailMessage.To.Add(Form1.tbTo.Text.ToLower())

            MyMailMessage.Subject = Form1.tbSu.Text
            MyMailMessage.Body = Form1.tbBo.Text

            'Add attachment
            Dim attachFile As New Attachment(Form1.tbAt.Text)
            MyMailMessage.Attachments.Add(attachFile)

            'Create the SMTPClient object and specify the SMTP server 
            Dim SMTPServer As New SmtpClient(Form1.tbSe.Text.ToLower())
            SMTPServer.Port = 587
            SMTPServer.Credentials = New System.Net.NetworkCredential(username, password)
            SMTPServer.EnableSsl = True

            Try
                SMTPServer.Send(MyMailMessage)
                MsgBox("Email Sent Successfully.", vbInformation, "Email Notification")
                username = ""
                password = ""
            Catch ex As SmtpException
                MessageBox.Show(ex.Message)

            End Try
        Catch EX As Exception
            MessageBox.Show(EX.Message)
        End Try
    End Sub

End Class

And this is the code to which my error is pointing to:
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.1
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict On
Option Explicit On


Namespace My
    
    'NOTE: This file is auto-generated; do not modify it directly.  To make changes,
    ' or if you encounter build errors in this file, go to the Project Designer
    ' (go to Project Properties or double-click the My Project node in
    ' Solution Explorer), and make changes on the Application tab.
    '
    Partial Friend Class MyApplication
        
        <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Public Sub New()
            MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
            Me.IsSingleInstance = false
            Me.EnableVisualStyles = true
            Me.SaveMySettingsOnExit = true
            Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
        End Sub
        
        <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
        Protected Overrides Sub OnCreateMainForm()
            Me.MainForm = Global.TeamSpec.Form1

        End Sub
    End Class
End Namespace


I cant seem to revert my changes and get rid of the error, i mean i have reverted the changes but its still throwing it at me.
AnswerRe: Infinite recursion wont go away. Pin
Dave Kreskowiak13-Feb-11 15:38
mveDave Kreskowiak13-Feb-11 15:38 
AnswerRe: Infinite recursion wont go away. Pin
Luc Pattyn14-Feb-11 1:10
sitebuilderLuc Pattyn14-Feb-11 1:10 
JokeRe: Infinite recursion wont go away. Pin
musefan14-Feb-11 5:15
musefan14-Feb-11 5:15 
GeneralRe: Infinite recursion wont go away. Pin
Henry Minute14-Feb-11 5:24
Henry Minute14-Feb-11 5:24 
JokeRe: Infinite recursion wont go away. Pin
musefan14-Feb-11 5:44
musefan14-Feb-11 5:44 
GeneralRe: Infinite recursion wont go away. Pin
Henry Minute14-Feb-11 5:49
Henry Minute14-Feb-11 5:49 
GeneralRe: Infinite recursion wont go away. Pin
musefan14-Feb-11 6:04
musefan14-Feb-11 6:04 
QuestionClick on the hyperlink and become an alert icon and also save to database Pin
Peggie199013-Feb-11 12:53
Peggie199013-Feb-11 12:53 
QuestionHow to Detect Music Device Pin
Pranit Kothari11-Feb-11 19:15
Pranit Kothari11-Feb-11 19:15 
AnswerRe: How to Detect Music Device - Repost Pin
Richard MacCutchan11-Feb-11 21:10
mveRichard MacCutchan11-Feb-11 21:10 
QuestionsessionState Pin
MWRivera11-Feb-11 6:43
MWRivera11-Feb-11 6:43 
AnswerRe: sessionState Pin
Not Active11-Feb-11 8:54
mentorNot Active11-Feb-11 8:54 
GeneralRe: sessionState Pin
MWRivera11-Feb-11 9:03
MWRivera11-Feb-11 9:03 
GeneralRe: sessionState Pin
Not Active11-Feb-11 10:14
mentorNot Active11-Feb-11 10:14 
GeneralRe: sessionState Pin
MWRivera11-Feb-11 10:22
MWRivera11-Feb-11 10:22 
GeneralRe: sessionState Pin
Pete O'Hanlon11-Feb-11 11:38
mvePete O'Hanlon11-Feb-11 11:38 
GeneralRe: sessionState Pin
MWRivera12-Feb-11 7:41
MWRivera12-Feb-11 7:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.