# IronRuby.Rack how to debug?

**URL:** <https://www.ruby-forum.com/t/ironruby-rack-how-to-debug/185126>\
**Category:** IronRuby\
**Created:** [March 14, 2010, 4:55pm UTC](https://www.ruby-forum.com/t/ironruby-rack-how-to-debug/185126 "2010-03-14T16:55:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 14, 2010, 4:55pm UTC](https://www.ruby-forum.com/t/ironruby-rack-how-to-debug/185126/1 "2010-03-14T16:55:26Z")

</div>

Hi

IronRuby.Rack isn’t passing the windows credentials through, but uses  
the  
credentials from the app pool so using a user + password in database.yml  
did  
change the error message.

development:  
mode: ADONET  
adapter: sqlserver  
database: mocktwitter\_dev  
username: sa  
password:  
host: (local)\SQLEXPRESS

I created my rails application under a virtual directory and then it  
gets  
confused about where it’s supposed to go

No route matches “/mocktwitter” with {:method=\>:get}

When I give it a proper site it’s a lot happier and will show me stuff  
but  
it still won’t display images, it’s odd because it will correctly read  
the  
css file from disk but not the image files.  
The image doesn’t seem to be handled by the rack handler so I wonder why  
it  
won’t show up at all. I verified permissions and gave everyone full  
control  
on that set of files.

I did build my IronRuby.Rack with the strong named RC3 assemblies  
because  
with a debug version it was a lot slower. Now initial startup time is  
comparable to an [ASP.NET](http://ASP.NET) application with a couple of referenced  
assemblies:  
+/- 10 seconds on my machine (core i7 w/ 10000RPM disks) when it needs  
to  
initialize a new application.

I am unable to debug the application though. If I put  
System::Diagnostics::Debugger.break somewhere it will correctly break  
there  
but eventually visual studio (2008 and 2010) will just get tired of it  
and  
claim they have to quit. I’ve seen that the debug windows gives me a  
lot of  
information and I was hoping that there would be some useful information  
there for me but because visual studio quits right at the interesting  
moment  
I’m unable to figure out what’s going on as nothing is printed in the  
sysinternals debugvw application.

* * *

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Web: [http://whiterabbitconsulting.eu](http://whiterabbitconsulting.eu) - [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))  
Microsoft IronRuby/C# MVP

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 15, 2010, 7:40am UTC](https://www.ruby-forum.com/t/ironruby-rack-how-to-debug/185126/2 "2010-03-15T07:40:53Z")

</div>

Ivan Porto C. wrote:

> I am unable to debug the application though. If I put  
> System::Diagnostics::Debugger.break somewhere it will correctly break there  
> but eventually visual studio (2008 and 2010) will just get tired of it and  
> claim they have to quit. I’ve seen that the debug windows gives me a lot of  
> information and I was hoping that there would be some useful information  
> there for me but because visual studio quits right at the interesting moment  
> I’m unable to figure out what’s going on as nothing is printed in the  
> sysinternals debugvw application.

You may also want to try WinDBG with the SOS extension. Here’s slides  
with code and examples on using WinDBG to debug .NET applications:

> **[Client Challenge](https://www.slideshare.net/CoryFoy/debugging-net-applications-with-windbg)**

What I’d try is using the File menu to attach to the process, then when  
it breaks typing in “.loadby sos mscorwks”. Next type in “sxe clr” and  
then “g”. It will now break on all CLR exceptions. You can type  
“!printexception” to see the exception details when it breaks, and “g”  
to make it go again. You can also type “!help” to see all of the SOS  
commands.

–  
Cory F.

> **[Cory Foy, LLC | Business Agility, Wardley Mapping and Organizational Consulting](http://www.coryfoy.com)**

[http://twitter.com/cory\_foy](http://twitter.com/cory_foy)

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 15, 2010, 7:23pm UTC](https://www.ruby-forum.com/t/ironruby-rack-how-to-debug/185126/3 "2010-03-15T19:23:57Z")

</div>

The issue just seems to be that the process is dying before Visual  
Studio can properly attach. Ivan, try using "  
System::Diagnostics::Debug.assert false" which will pop up a dialog box,  
thus blocking the thread, but without using the “int 3” x86 instruction  
as System::Diagnostics::Debugger.break would. The latter might cause  
some issues.

Also, could there be any issue with the fact that [ASP.Net](http://ASP.Net) is running a  
service? Some dialog boxes might be getting hidden since services run in  
their own hidden workspace/workstation (I think)

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 15, 2010, 7:59pm UTC](https://www.ruby-forum.com/t/ironruby-rack-how-to-debug/185126/4 "2010-03-15T19:59:40Z")

</div>

I can attach and step through but just when the interesting bit occurs  
visual studio takes a hike

## but will try this again later

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Web: [http://whiterabbitconsulting.eu](http://whiterabbitconsulting.eu) - [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([IronRuby in Action - Ivan Porto Carrero and Adam Burmister | Manning](http://manning.com/carrero))  
Microsoft IronRuby/C# MVP

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 15, 2010, 8:11pm UTC](https://www.ruby-forum.com/t/ironruby-rack-how-to-debug/185126/5 "2010-03-15T20:11:23Z")

</div>

In that case, windbg might help. Itâ€™s potentially a bit more robust  
since it offers fewer features. Btw, I often disable â€œTools | Options |  
Debugging | Enable property evaluation and implicit function callsâ€ in  
Visual Studio so that it does not try to implicitly run code in the  
process being debugged when you hit a breakpoint or step over a line of  
code. If I need to evaluate some property when stopped at a breakpoint,  
I do that explicity using the Immediate Window.

From: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Ivan Porto  
Carrero  
Sent: Monday, March 15, 2010 11:49 AM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IronRuby.Rack how to debug?

I can attach and step through but just when the interesting bit occurs  
visual studio takes a hike

## but will try this again later

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Web: [http://whiterabbitconsulting.eu](http://whiterabbitconsulting.eu) - [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([IronRuby in Action - Ivan Porto Carrero and Adam Burmister | Manning](http://manning.com/carrero))  
Microsoft IronRuby/C# MVP

On Mon, Mar 15, 2010 at 7:18 PM, Shri B.  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:  
The issue just seems to be that the process is dying before Visual  
Studio can properly attach. Ivan, try using "  
System::Diagnostics::Debug.assert false" which will pop up a dialog box,  
thus blocking the thread, but without using the “int 3” x86 instruction  
as System::Diagnostics::Debugger.break would. The latter might cause  
some issues.

Also, could there be any issue with the fact that [ASP.Net](http://ASP.Net) is running a  
service? Some dialog boxes might be getting hidden since services run in  
their own hidden workspace/workstation (I think)

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 31, 2010, 7:40am UTC](https://www.ruby-forum.com/t/ironruby-rack-how-to-debug/185126/6 "2010-03-31T07:40:28Z")

</div>

Ivan,

When using IronRuby.Rack and debugging the ruby code running, keep a few  
things in mind:

1. 

```
  Enable debug mode for DLR code in your appâ€™s web.config (in the 

```

Microsoft.Scripting section).

1. 

```
  Because VS breakpoints in blocks donâ€™t work yet, using 

```

Debug.Assert will do the job.

1. 

```
  IIS has a timeout of 60 seconds per request, which can be 

```

annoying when debugging. In the AppPool configuration that your  
application is running in try to max the timeout out so the process you  
want to debug stays around.

1. 

```
  Use WinDBG if you want to â€œman upâ€, but the VS debugger will be 

```

just fine.

Ivan, your â€œNo route matches “/mocktwitter” with {:method=\>:get}â€ error  
is because you need to tell Rails what the root directory on the  
web-server is so it can route appropriately. To see how to do this, look  
at the IronRuby.Rails.Example  
environment.rb[http://github.com/ironruby/ironruby/blob/master/Merlin/Main/Hosts/IronRuby.Rack/IronRuby.Rails.Example/config/environment.rb#L10](http://github.com/ironruby/ironruby/blob/master/Merlin/Main/Hosts/IronRuby.Rack/IronRuby.Rails.Example/config/environment.rb#L10):

Rails::Initializer.run do |config|  
config.action\_controller.relative\_url\_root = “/IronRuby.Rails.Example”  
if ENV[‘RACK\_ENV’] == ‘production’

# â€¦

end

Also, I usually set up a separate AppPool, and set it to run as a  
specific Windows user, so I can grant read-only permissions to that user  
for the Ruby stdlib/gems, and read-write access for the app. Then you  
donâ€™t have to grant permissions to IIS\_IUSRS for all your stuff.

~js
