Find Possible Solution for ArcSWAT Errors with ildasm.exe.

For more details about ArcSWAT structure, please check out my another post: ArcSWAT Structure – Developer View.

Please Note:

  • SWATEditor and SWAT Check are also .NET programs. The method post here could be also used on them.
  • All the analysis and screenshots are based on ArcGIS 2009.10.1. It’s similar to other versions.
  • MSIL code given by ildasm.exe is not easy to read. For more readable solution, please consider to use free .NET decompilers out there. They could decompile .NET in C# which is more easier to read. I’m using dotPeek from JetBrains. The only problem is some methods couldn’t be decompiled in these tools and could only be analyzed in ildasm.exe.
  • Welcome to any discussions on this subject. Please send me email on


  • ildasm.exe
  • Where are the ArcSWAT assemblies?
  • Which assembly should be looked into?
  • Find codes corresponding to one ArcSWAT menu item
  • Find out what happened when one ArcSWAT menu item is clicked
  • What if error happens in a window pop-up by ArcSWAT?
  • Two kinds of errors

ArcSWAT is the most popular SWAT interface. It’s free-to-use but not open source. When something unexpected happened (like the one shown below), it’s not possible to look into source codes like SWAT model itself (please refer to my another post: Compile and Run SWAT with Photran + MinGW – the easiest way to remove mathematical errors from SWAT). So, how to find possible solutions?

The answer is decompiling/disassembling.

ArcSWAT consists of six .NET assemblies (shown below), which are corresponding to six menus in ArcSWAT toolbar (shown below). Decompile/Disassemble would show background codes in C# or Microsoft intermediate language (MSIL) code format, from which the background processes under all ArcSWAT menu could be analyzed and possible solutions could be reached.


ildasm.exe is a tool in Visual Studio and Windows SDK. It could parse any .NET Framework .exe or .dll assembly, and shows the information in human-readable format. A simple tutorial could be found here: If it’s impossible to install Visual Studio, please get Windows SDK at for Windows 7 and .NET 4.0. It’s free-to-use.

Where are the ArcSWAT assemblies?

They are located in ArcSWAT installation folder, which is usually c:\swat\ArcSWAT.

Which assembly should be looked into?

From ArcSWAT toolbar, the analysis assembly could be determined.

  • SWAT_PM2.dll, project management, corresponding to “SWAT Project Setup” menu in ArcSWAT toolbar.
  • SWAT_WD.dll, watershed delineation, corresponding to “Watershed Delineator” menu in ArcSWAT toolbar
  • SWAT_HRU.dll, HRU definition, corresponding to “HRU Analysis” menu in ArcSWAT toolbar
  • SWAT_InputFileGen.dll, input generation, corresponding to “Write Input Tables” menu in ArcSWAT toolbar
  • SWAT_InputFileEdit.dll, input edit, corresponding to “Edit SWAT Input” menu in ArcSWAT toolbar
  • SWAT_RunSWAT.dll, swat simulation, corresponding to “SWAT Simulation” menu in ArcSWAT toolbar

Find codes corresponding to one ArcSWAT menu item

One ArcSWAT menu item is corresponding to one class in one of the six assemblies. The name of these class would usually has a name starting with “cmb” or “com”. For example below, in SWAT_PM2.dll, there is class named cmbHelp. It’s corresponding to menu “ArcSWAT Help…”. To confirm this, expand class cmbHelp in ildasm.exe and double click on method get_Name to open it.

Considering name convention, it’s easy to find these classes just from the menu name.

Find out what happened when one ArcSWAT menu item is clicked

Method onClick is implemented in all classes corresponding to ArcSWAT menu items. The codes in this method will be executed when corresponding menu item is clicked. Double-click this method node in ildasm could open the codes. This is where should be looked into.

What if error happens in a window pop-up by ArcSWAT?

Most of the ArcSWAT menu item would pop-up a window and then further operation could be done in this window. A very good example is the “Watershed Delineation” window shown below.

In this case, the class corresponding to the window should be found first and then find the method corresponding to a specific button.

For “Watershed Delineation” window, follow steps below.

  1. Open SWAT_WD.dll with ildasm.exe.
  2. Find the class for menu “Automatic Watershed Delineation” which is “ComAutoDelin”.
  3. Expand class ComAutoDeline and double-click method “ICommand_OnClick” to open the codes window.
  4. Find the class name for the window In the codes window, which is frmMainForm. The name of classes corresponding to windows usually starts with “frm”.
  5. Find class frmMainForm in ildasm.exe and expand to check the methods. The name of methods corresponding to button clicks usually like “[button name]_click”, where button name is the name of the button. These methods are the codes corresponding to the buttons.

Two kinds of errors

Once the method body is found, possible solutions could be figured out through analysis of the codes. There would be two kinds of error.

  1. Data Problem ArcSWAT has special requirements on input data. Giving data in a different format or value would cause ArcSWAT give errors. Analysis on the codes given by ildasm.exe could help locate the problematic data.
  2. Software Problem ArcSWAT continues to be improved. There may be still some bugs there and would stuck you someday. Analysis on the codes could help locate the bug and report to the develop team.

© 2000 – 2021 SWAT Output Viewer All rights reserved