views:

107

answers:

2

Is there a way in VS 2008 to specify I want to include pdb files for all/some dlls in the xap generated?

Background

We have written a Silverlight framework that is used by multiple projects with some base UI controls and functionality. These framework dlls and pdbs are brought into projects via svn:externals into a lib folder. The Silverlight applications reference the dlls from the project's lib folder with Copy Local set to True. When compiled, the dll is included in the xap, but the pdb is not. If I have a precondition (i.e. ItemSource of a control is not set) of the framework dll is not satisfied, an error is thrown. I have both "thrown" and "User-Unhandled" CLR Exceptions checked in the Exceptions Dialog within VS 2008. With VS 2008 attached, I get no errors reported. Since the standard generated Application_UnhandledException handler does not alert unhandled errors if a debugger is attached and for some reason VS does not break on the error. If I manually include the pdbs in the xap, VS stops on the correct line showing me the error.

    Private Sub Application_UnhandledException(ByVal sender As Object, ByVal e As ApplicationUnhandledExceptionEventArgs) Handles Me.UnhandledException

        ' If the app is running outside of the debugger then report the exception using
        ' the browser's exception mechanism. On IE this will display it a yellow alert 
        ' icon in the status bar and Firefox will display a script error.
        If Not System.Diagnostics.Debugger.IsAttached Then

            ' NOTE: This will allow the application to continue running after an exception has been thrown
            ' but not handled. 
            ' For production applications this error handling should be replaced with something that will 
            ' report the error to the website and stop the application.
            e.Handled = True
            Deployment.Current.Dispatcher.BeginInvoke(New Action(Of ApplicationUnhandledExceptionEventArgs)(AddressOf ReportErrorToDOM), e)
        End If
    End Sub
A: 

You should just place the PDB files next to the XAP. You can do this using a post-build action if you like.

Make sure that your web server can serve PDBs, they are locked down in some default configurations. Just request the PDB through your browser and see if it will download. If not, add a MIME type to your server for x-application/octet-stream.

Jeff Wilcox
A: 

Hi Jeff

Is it possible for the PDB for the Silverlight application itself to be included in the XAP? I'm trying to get client error messages to show me line numbers.

Thanks

SilverlightFox
You can manually add them to the xap and you will be able to break into the code. I still don't believe that the line numbers were showing up for some reason.
Mike Schall