views:

280

answers:

3

I'm trying to debug a slightly-modified version of the ADO.NET POCO Entity Generator template using the directions Oleg Sych published a few years back. I modified the DbgJITDebugLaunchSetting key as recommended.

I get a dialog indicating that a user-defined breakpoint has been hit. However, rather than being presented with the option to start a new instance of VS 2010 to debug, the original instance of VS 2010 just crashes and auto-restarts.

Is it possible to debug T4 templates with VS 2010?

+2  A: 

in Visual Studio 2010 you need to call Debugger.Launch() before Debugger.Break().

Oleg Sych
@Oleg: That did it as far as launching a new debugger instance, but now I get No Source Available for Call stack location: *13gocwvx!Microsoft.VisualStudio.TextTemplating9936422A04D1D8AC631D9CB3A394DD16.GeneratedTextTransformation.TransformText() + 0x34 bytes.* Any thoughts?
Eric J.
Accepting because it was partially correct, but I still get the above error.
Eric J.
+1  A: 

You also need debug=true:

<@#template debug="true" #> System.Diagnostics.Debugger.Launch(); Debugger.Break();

http://msdn.microsoft.com/en-us/library/bb126338.aspx

Tim Fischer
@Tim: Thanks, I have debug set to true already.
Eric J.
A: 

Final solution which works for me:

regedit:

Key (x86 systems): HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework

Key (x64 systems): HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework

value: DbgJITDebugLaunchSetting

data: 0x2

tt template:

<#@ template debug="true" hostSpecific="true"  #>
<# System.Diagnostics.Debugger.Launch(); Debugger.Break(); #>
psulek