How to fix the error "aspnet_merge.exe exited with code 1"

I use the free add-on to Visual Studio called Visual Studio 2005 Web Deployment Projects when creating .NET websites at my job. One great feature of this add-on is that it allows me to merge all the .dll files that are created when the "code behind" files of my aspx pages are compiled to one single .dll - with any name I specify. This eliminates the nightmare of dozens of weirdly named .dll files for EACH aspx page, which will be named something different every time you build.

I never had any problems with it, until the day I saw this error message:

ASPNET_MERGE.EXE EXITED WITH CODE 1

Helpful, right? Some googling turned up how I could get a more useful, verbose error message. In Visual Studio, go to Tools > Options > Projects & Solutions > Build and Run. Then set the MSBuild output verbosity to Diagnostic.

The next time I tried to build my Web Deployment Project, I was able to click on the "Output" tab (or Ctrl + W, O) to see a detailed description of what went wrong:

    An error occurred when merging assemblies: 
         ILMerge.Merge: ERROR!!: Duplicate type 'Admin_Success' found in assembly 'App_Web_s7km_dqp'.
    C:\Program Files\MSBuild\Microsoft\WebDeployment\v8.0\Microsoft.WebDeployment.targets(574,9): 
         error MSB6006: "aspnet_merge.exe" exited with code 1.

    Done executing task "AspNetMerge" -- FAILED.
    Done building target "AspNetMerge" in project "Web_deploy1.wdproj" -- FAILED.

Like almost everyone else who had this error, I found that I had two classes with the same name. This happened when I copy and pasted code into a new .cs file, gave it a new file name...but neglected to change the actual name of the class. I gave the class I had copied a new name that matched its filename, then rebuilt and everything worked.