For more details about ArcSWAT structure, please check out my another post: ArcSWAT Structure – Developer View.
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: http://msdn.microsoft.com/en-us/library/aa309387(v=vs.71).aspx. If it’s impossible to install Visual Studio, please get Windows SDK at http://www.microsoft.com/en-ca/download/details.aspx?id=8279 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.
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.
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.
© 2000 – 2021 SWAT Output Viewer All rights reserved