Here Is A Article Talking About The Ability To Put Some Of Your Config Info In Another Config File When Using Aspnet

Here is a article talking about the ability to put some of your .config info in another config file when using asp.net

http://www.beansoftware.com/ASP.NET-Tutorials/Multiple-Config.aspx

What I found most interesting is that it says that changing the otherFile.config will not reset your app.

I am guessing that it also means that it won’t find your new values until the app is reloaded, but if it DID find the new values w/o a reload that would be great.

<?xml version=1.0?>
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
        <compilation debug=false strict=false explicit=true />
    </system.web>
    <appSettings file=externalSettings.config/>
</configuration>

I also wonder if you could have more than 1 appSettings external file.

Sorting a generic List(Of T) using IComparable(Of T)

List(Of T) supports sorting through it’s Sort method.  When you call Sort it will use the default comparer for the items it contans.  So if you have a custom class in there, you need to implement IComparable or IComparable(Of T). 

Here is some code that shows how to do this.  This code sorts lowest to highest.

    Public Function CompareTo(ByVal other As CustomClass) As Integer Implements System.IComparable(Of CustomClass).CompareTo
Dim myscore As Integer = Me.SomeValue
Dim otherscore As Integer = other.SomeValue
If myscore > otherscore Then
Return 1
ElseIf myscore = otherscore Then
Return 0
Else
Return -1
End If
End Function

IBiz Quickbooks Integrator

nSoftware just released a product called IBiz Integrator for Quickbooks, which is supposed to enable one to integrate their applicaiton with Quickbooks via QBXML.

A comprehensive suite of Internet-enabled components for QuickBooks (QBXML) Integration. Includes easy-to-use components for accessing QuickBooks constructs and automating accounting tasks.

Should be work looking into for QB applications.

Exceptions in .Net

I found this snippet on another site, and it looks like it comes from the book I just bought about building frameworks from the guys that worked on the .net framework.

  • DO report execution failures by throwing exceptions.
  • CONSIDER terminating the process by calling System.Environment.FailFast (.NET 2.0) instead of throwing an exception, if your code reaches a situation where you consider it unsafe for further execution.
  • DO NOT use exceptions for the normal flow of control, if possible.
  • CONSIDER the performance implications of throwing exceptions.
  • DO document all exceptions thrown by publicly callable members because of a violation of the member contract and treat them as part of your contract.
  • DO NOT have public members that can either throw or not based on some option such as a bool parameter (.e.g., bool throwOnError)
  • DO NOT have public members that return exceptions as the return value or as an out parameter.
  • CONSIDER using exception builder methods.
  • DO NOT throw exceptions from exception filter blocks
  • AVOID explicitly throwing exceptions from finally blocks.
  • DO throw the most specific (the most derived) exception that makes sense.
  • DO NOT swallow errors by catching nonspecifc exceptions ( e.g., catch (Exception e) { } // swallowed whole!)
  • CONSIDER catching a specific exception when you understand why it was thrown in a given context and you can respond to the failure programmatically.
  • DO Clean up any side effects when throwing an exception. For example, if a Hashtable.Insert method throws an exception, the caller can assume that the specified item was not added to the Hashtable.
  • DO NOT derive all new exceptions directly from the base class SystemException. Inherit from SystemException only when creating new exceptions in System namespaces. Inherit from ApplicationException when creating new exceptions in other namespaces.
  • DO use the predefined exceptions types. Define new exception types only for programmatic scenarios.
  • DO NOT overcatch. Exceptions should often simply be allowed to propagate up the call stack.
  • DO prefer using an empty throw when catching and rethrowing an exception. This is the best way to preserve the exception call stack.
  • AVOID creating custom exception classes when there is already an exception type that’s “good enough”.
  • DO Design classes so that in the normal course of use an exception will never be thrown.
  • DO NOT return Error Codes!
  • Printing a VB.Net Form

    I found this useful code at VB-Helper.com

     

    .csharpcode
    {
    font-size: small;
    color: black;
    font-family: Courier New , Courier, Monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }

    .csharpcode pre { margin: 0em; }

    .csharpcode .rem { color: #008000; }

    .csharpcode .kwrd { color: #0000ff; }

    .csharpcode .str { color: #006080; }

    .csharpcode .op { color: #0000c0; }

    .csharpcode .preproc { color: #cc6633; }

    .csharpcode .asp { background-color: #ffff00; }

    .csharpcode .html { color: #800000; }

    .csharpcode .attr { color: #ff0000; }

    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }

    .csharpcode .lnum { color: #606060; }

    #Region "Print"
        Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal _
        hdcDest As IntPtr, ByVal nXDest As Integer, ByVal _
        nYDest As Integer, ByVal nWidth As Integer, ByVal _
        nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc _
        As Integer, ByVal nYSrc As Integer, ByVal dwRop As _
        System.Int32) As Boolean
        Private Const SRCCOPY As Integer = &HCC0020
    
        ' Variables used to print.
        Private m_PrintBitmap As Bitmap
        Private WithEvents m_PrintDocument As Printing.PrintDocument
    
        Private Sub PrintForm()
            ' Copy the form's image into a bitmap.
            m_PrintBitmap = GetFormImage()
    
            ' Make a PrintDocument and print.
            MsgBox(m_PrintDocument.PrinterSettings.PrinterName)
            m_PrintDocument = New PrintDocument
            m_PrintDocument.Print()
        End Sub
    
        Private Function GetFormImage() As Bitmap
            ' Get this form's Graphics object.
            Dim me_gr As Graphics = Me.CreateGraphics
    
            ' Make a Bitmap to hold the image.
            Dim bm As New Bitmap(Me.ClientSize.Width, _
                Me.ClientSize.Height, me_gr)
            Dim bm_gr As Graphics = Graphics.FromImage(bm)
            Dim bm_hdc As IntPtr = bm_gr.GetHdc
    
            ' Get the form's hDC. We must do this after 
            ' creating the new Bitmap, which uses me_gr.
            Dim me_hdc As IntPtr = me_gr.GetHdc
    
            ' BitBlt the form's image onto the Bitmap.
            BitBlt(bm_hdc, 0, 0, Me.ClientSize.Width, _
                Me.ClientSize.Height, _
                me_hdc, 0, 0, SRCCOPY)
            me_gr.ReleaseHdc(me_hdc)
            bm_gr.ReleaseHdc(bm_hdc)
    
            ' Return the result.
            Return bm
        End Function
    
        ' Print the form image.
        Private Sub m_PrintDocument_PrintPage(ByVal sender As _
            Object, ByVal e As _
            System.Drawing.Printing.PrintPageEventArgs) Handles _
            m_PrintDocument.PrintPage
            ' Draw the image centered.
            Dim x As Integer = e.MarginBounds.X + _
                (e.MarginBounds.Width - m_PrintBitmap.Width)  2
            Dim y As Integer = e.MarginBounds.Y + _
                (e.MarginBounds.Height - m_PrintBitmap.Height)  2
            e.Graphics.DrawImage(m_PrintBitmap, x, y)
    
            ' There's only one page.
            e.HasMorePages = False
        End Sub
    
    #End Region

    Problems moving from System.Web.Mail to System.Net.Mail

    I recently went through the painful process of updating all our codebase to remove all warning messages after our “successful” convesion from .net 1.1 to 2.0.

    After I made all the adjustments to remove all warnings, all seemd to be well.  In fact, it was going to well, as this morning I relized that I hadn’t seen an exception report come through my email in a week.

    Sure enough, I went into the database where I log everything and found exceptions that were not being emailed to our development team.

    The exceptions that were being thrown when we tried to email were stuff like this:

    Email address problemsError sending Error Report: Message: The specified string is not in the form required for an e-mail address.
    Stack:   at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName)
       at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset)
       at System.Net.Mail.MailAddressCollection.ParseValue(String addresses)
       at System.Net.Mail.MailAddressCollection.Add(String addresses)
       at System.Net.Mail.Message..ctor(String from, String to)
       at System.Net.Mail.MailMessage..ctor(String from, String to)
       at System.Net.Mail.MailMessage..ctor(String from, String to, String subject, String body)
       at Walshgroup.Logging.ApplicationAudit.EmailErrorToDevelopmentTeam(String sErrorMessage, Int32 iLoginID) in x.vb:line 586 on machine y
    Subject problemsError sending Error Report: Message: The specified string is not in the form required for a subject.
    Stack:   at System.Net.Mail.Message.set_Subject(String value)
       at System.Net.Mail.MailMessage..ctor(String from, String to, String subject, String body)
       at Walshgroup.Logging.ApplicationAudit.EmailErrorToDevelopmentTeam(String sErrorMessage, Int32 iLoginID) in C:x.vb:line 586 on machine y

    It turns out that we were doing 2 things that System.Web.Mail seemed to accept, but System.Net.Mail did not.

    Email Address: We were using the MS Outlook way of email concatenation (using a semicolon) to send an email to multiple people (e.g. bill@asdf.com;jack@asdf.com;pete@asdf.com).  Once I changed it to use commas, everything worked, but we still had errors related to the subject line.

    What we were doing for the subject line was simply to take the first 50 characters of the email error message.  In this case, this included some CRLF.  Once those were removed the email sent w/o a problem.

    For more info on these classes check out http://www.systemwebmail.com/ and http://www.systemnetmail.com/.

    Activate Flash, Movies, and other ActiveX controls

    Recently Microsoft lost a patent judgement, which resulted in them pushing down an “update” to IE that forces you to click on any embedded object to “activate” it.

    Embedded objects can be flash movies, video clips, audio, etc.

    This is really bad for sites that use flash.  Things like navigation and rollovers don’t work until you first click on them.

    This article talks about the work around, and how you can incorporate this into your ASP.NET projects.

    http://www.codeproject.com/aspnet/IEActiveXActivation.asp