This guide demonstrates how to create a new project in Microsoft Visual Studio for a new APSIM model.
In Visual Studio, create a new project of type “Class Library”. Uncheck the “create directory” box.
Add a reference to CSDotNetComponentInterface.dll and CMPServices.dll to the project (Right click on References in the Solution Explorer, click the Browse tab and navigate to the DLL.
Also add an existing item to the project: Model\CSDotNetComponentInterface\EntryPoints.cs. Make sure you use the "Add as link" option at the bottom of the window:
Save the solution, project and class file name.
The Solution Explorer should look like this:
Debugging APSIM in Visual Studio
- Start the APSIM GUI and open the simulation (<your simulation>.apsim).
- Click the Create .sim button in the top right hand corner. This will create a .sim file in the same directory as the .apsim file. Or run ApsimToSim.exe transform the apsim-file to a sim-file
- Open your Visual Studio project.
- Open the Properties window of the project and go to the Debug tab.
- Select the Start external program and enter the path to the ApsimModel.exe executable.
- Set the working directory to the one containing the .sim file.
- Insert the name of the .sim file within quotation marks into the Command line arguments text box. You may need to insert the full name (including path).
- Make sure that Apsim is not running in a separate window (e.g. from when you created the .sim file).
- You should be ready to debug.