Debugging Silverlight Applications in Out Of Browser Mode


On an internal mailing list yesterday, someone asked how to debug their Silverlight 3 application as it runs Out of Browser.  They were seeing some behavior that would only reproduce in the first few seconds and only in OOB mode.  Fortunately, you can install your app locally and then debug it directly in the Out of Browser window.

In the Silverlight project properties, on the debug tab, you can enable launching it as an OOB application:

enableOOBdebugging

The drop down box contains all of the web projects in the solution which consume your Silverlight application.  Because they are treated as different installs by the runtime, you may want to change this setting if issues occur when installing from one web project but not another.  The notice below the dropdown simply indicates that you haven’t installed the Silverlight application in the context of that web project yet.  If the notice does not appear, then you’re good to go.

The next step after enabling OOB debugging is to set your Silverlight app to the startup project.  Normally the web project is the startup project, and it hosts the Silverlight app; in this case, we don’t want to run the website.  To set the startup project, just right-click the project in Solution Explorer and select ‘Set as Startup Project’. 

setStartupProject

You’ll know which project is set as it will be in bold in Solution Explorer.

Now when you start debugging, the application will launch in Out of Browser mode.  To go back to debugging in the web site’s context, simply change the web project back to being the startup project.

Comments (7)

  1. Chris says:

    When hitting Run, I get this error and can’t debug it:

    Warning: A StringBuilder buffer has been overflowed by unmanaged code. The process may become unstable. Insufficient capacity allocated to the StringBuilder before marshaling it.

    Any ideas?

  2. Bernhard says:

    I get the same error …. quite annoying

  3. sladapter says:

    Jimmy,

    This debugging method doesn't work for debugging Services. If I have RIA service under the solution, I can't set the Silverlight project as start up project. Otherwise RIA service call would fail.

    Seems the only way to debug the service is to start the  OOB app normally, then use Attach to Process feature to attach to the WebDev process.

    Any other better options?

  4. Jimmy Lewis says:

    @sladapter: first thing that comes to mind is to make your web project run on your local IIS, instead of the WebDev server.  Haven't tried it, so I'm not positive if that would work around the problem…

  5. swathi says:

    it save me a day,, thanks a looooooooooooooooooooooooooooot

  6. Chris Poulter says:

    As a Silverlight newbie, good to know.

  7. NewSL says:

    How to debug both OOB and Web local at the same time?

    Thank you.