debug vs release

M

Mel

I want to send an email in release mode but not in debug mode, how
would I accomplish this?

Here is my email code (using vb.net, visual studio 2005, winxp pro
sp2):
Try
Dim MailMsg As New MailMessage(New
MailAddress("(e-mail address removed)"), New
MailAddress("(e-mail address removed)")) 'from, to
MailMsg.Subject = "Program Generated an Error"
MailMsg.Body = "List Error number and description here"
MailMsg.Priority = MailPriority.High
MailMsg.IsBodyHtml = True
'Smtpclient to send the mail message
Dim SmtpMail As New SmtpClient
SmtpMail.Host = "MYEXCHANGESERVER"
SmtpMail.Send(MailMsg) 'sends the email
Catch ex As System.Exception
'Message Error
End Try
 
K

Ken Tucker [MVP]

Try something like this

SmtpMail.Host = "MYEXCHANGESERVER"
#If Not Debug then
SmtpMail.Send(MailMsg) 'sends the email
#Endif
Catch ex As System.Exception

Ken
 
M

Mel

Try something like this

             SmtpMail.Host = "MYEXCHANGESERVER"
#If Not Debug then
             SmtpMail.Send(MailMsg)  'sends the email
#Endif
         Catch ex As System.Exception

Ken
--------------------------






- Show quoted text -

Thanks, that worked great.
 
M

Michel Posseth [MCP]

"rowe_newsgroups" <[email protected]> schreef in bericht
Thanks, that worked great.
You can also use System.Diagnostics.Debugger.IsAttached to detect
whether the application is being debugged, this can have benefits over
using a precompiler statement.

Seth Rowe [MVP]
http://sethrowe.blogspot.com/


Yes advantages and dissadvantages :)

1 . if using System.Diagnostics.Debugger.IsAttached this would mean that
the code is delivered with your assembly
while in Ken`s solution the code is there when needed and removed when it
isn`t ( so the mail code would not be in the assembly )

2. debugging the compiled executable because it doesn`t send e-mails is
getting impossible

3. using runtime checks makes the app slower , while using a precompile
contstant the app gets faster when you remove the unnecesary code


regards

Michel Posseth [MCP]
http://www.vbdotnetcoder.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top