My favorites | Sign in
Project Logo
                
Search
for
Updated Oct 16, 2009 by simon.cropp
DebugExceptionsOrStepThroughTemplates  
How to debug exceptions or step through templates.

Note: All examples are based on the latest version of NHaml. Check the GettingNHaml for information about getting the latest version.

Note: All examples where code is used are in C# unless specified otherwise

Enable template debugging

Set the config setting

  <nhaml outputDebugFiles="true">
...
  </nhaml>

Temp Directory

The next time a view is compiled the generated source file will be save to disk.

The location for these source files derived from the location of

Assembly.GetExecutingAssembly() 
Path.GetTempPath()

and nhamltemp

So, for example, if your app bin is

C:\Code\MVCSite\bin

And your temp path is

C:\Temp

Your nhaml temp directory will be in

C:\Temp\nhamlTemp\C_Code_MVCSite_bin

The path will also be written to Debug using

Debug.WriteLine()

Diagnosing a Template Exception

Example template with exception

- string x = null
= x.Substring(0,4)

Enable "Break On Exceptions" in Visual Studio

Execute the template. Visual Studio will break into file when the exception is thrown.

Stepping Through Template Code

Execute the template at least once. This will cause a file for that template to be save to the nhamltemp directory.

Open the file in Visual Studio and add a breakpoint on the desired line

Execute the template in Debug Mode

Notes:


Sign in to add a comment
Hosted by Google Code