Debugging EntLib without modifying all my references in my projects

Topics: Building and extending application blocks, General discussion
Feb 24, 2011 at 7:38 PM

Hi,

I would like to debug Enterprise Library in my application context. My application references signed version with specific version enabled, and I would like NOT modify my references just to debug to ease the process.

So I think to build Ent Lib and try to use DEVPATH to locate rebuilt Ent Lib assemblies, but they were ignored since rebuilt assemblies did not contain the public key of the assembly my application references...

I think it would be possible if you provide public key (extracted from your key pair with sn.exe) to allow delay signing (that you could also set up for next releases perhaps ?). Could you provide the public key in a file ?

Tell me if I am wrong with my approach to debug Ent Lib. If so, can you give me another way to do what I would like to do ?

Thanks

Clément

 

Feb 24, 2011 at 10:04 PM

Grab the pdb files for Enterprise Library. If you're using Entlib 5.0, they're included in the installer. If you're using 4.1, they're available from the Downloads tab here on Codeplex. Drop the pdb files next to your entlib assemblies.

Next, unpack the Entlib source code.

At this point, you should be able to debug into entlib. The VS debugger should prompt you for the source when you step in, just browse to the corresponding file in the source code you unpacked and you're fine.

Jun 16, 2011 at 2:21 AM
ctavares wrote:

Grab the pdb files for Enterprise Library. If you're using Entlib 5.0, they're included in the installer. If you're using 4.1, they're available from the Downloads tab here on Codeplex. Drop the pdb files next to your entlib assemblies.

Next, unpack the Entlib source code.

At this point, you should be able to debug into entlib. The VS debugger should prompt you for the source when you step in, just browse to the corresponding file in the source code you unpacked and you're fine.

ctavares: This doesn't seem to work for me.  I have been trying to do this for a while.  The *.pdb files are present in the bin directory of my web application, but when I step through the code and an exception gets thrown, I would like it to navigate to the EntLib50Src that I have unpacked, instead, I just get the exception.

The only way I'm managing this is taking turns to debug either my application, or EntLib by starting multiple instances of VS2010, and then doing a full rebuild of my application, then switching to the source code for entlib50 and manually attaching the debugger to the aspnet_wp.exe process from there.

Am I missing some setting or something?

Thanks in advance!

a

Jun 16, 2011 at 4:54 AM

Hi,

I'm not sure about your exact scenario, but how did you debug your code? Through Step Into (F11) or Step Over (F10)?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 16, 2011 at 7:09 AM

Hi

I'm using F11.

Jun 16, 2011 at 10:07 AM

Have you tried the following steps mentioned in this related thread  - http://entlib.codeplex.com/Thread/View.aspx?ThreadId=39988 regarding this.

To reiterate the steps, here it is;

1. Copy the .pdb file where the class you wish to debug belongs to the bin/Debug folder of your project.  
2. Open your project and in the Tools menu in VisualStudio, select Options. 
3. Go to the Debugging -> Symbols node. 
4. Click the folder icon and specify the path where you placed the .pdb file in the Symbol file (.pdb) locations listbox.
5. Click Ok.
6. Place a breakpoint in your app and then run it.
7. Press F11 upon hitting the breakpoint. 
8. You will then be prompted for the location of the class you wish to debug. You can easily locate that since you can see its original location in the dialog box. 

Also note that the Entlib 5.0 pdb files are included in the bin directory where you install it.

HTH,

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 18, 2011 at 6:38 AM

That worked brilliantly!  Thank you very much.  It had never occurred to me check the symbols node.  It had no path specified.

Thank you very much once again.

Cheers.

Jun 20, 2011 at 12:49 AM
agupta80 wrote:

That worked brilliantly!  Thank you very much.  It had never occurred to me check the symbols node.  It had no path specified.

Thank you very much once again.

Cheers.

I came across the same issue again, this time on a different computer and I was not able to fix it using the above method.  So upon further research, I realised that if I had been prompted for a source file (.cs) earlier while debugging and the I had pressed cancel to ignore loading of the source file, the debugger will not prompt me again if it can't find the source file.  It'll simply step over and continue as normal.  This behaviour can be changed by removing the relevant entries in the "Don not look for these source files" in the "Debug Source Files" node in the solution properties dialog box (right click solution name --> Properties).

Hope this helps someone.

Jun 27, 2011 at 6:12 AM

Hi folks,

I seem to have run into this problem again, but, this time, I just cannot get it to work!

Now, all I seem to get is the metadata file if I press F12, but stepping through doesn't seem to do anything, and I go straight to the exception handling code.

HELP!

Jun 27, 2011 at 11:36 AM

Hi,

I'm not sure what you are trying to do but I believe F12 is not for debugging. It lets you go to the definition of the current object. If the object is referenced through project reference, then you will be directed to the code, otherwise if it is a binary reference (like the EntLib assemblies) you will be directed to the metadata file.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 27, 2011 at 11:20 PM
Edited Jun 28, 2011 at 12:55 AM

Hi,

Thank you for your reply.  My apologies for the confusion.  Currently, when I'm debugging, I have a breakpoint on the line below:

command.ExecuteReader(CommandBehavior.CloseConnection);

My method looks like this:

protected DbDataReader ExecuteReader(DbCommand command)
{
  try
  {
    // Open the connection
    OpenConnection(command);

    // Execute the command, and return the result
    return command.ExecuteReader(CommandBehavior.CloseConnection);
  }
  finally
  {
    CloseConnection(command);
  }
}

When I hit F11, I would expect it to step into the Enterprise Library code so I can see what's going on there, but, instead, my execution proceeds to the

finally

block and my external exception handling code. The problem I'm having is I'm trying to see why the output cursor "cur_OUT" is not being added to my parameters list when I'm using the msdaora provider.

Furthermore, the stacktrace I'm getting is indicative that I'm actually not going through the Enterprise Library code at all, and instead just going through the standard System.Data functionality, which doesn't seem right at all.  My stacktrace is included below for reference:

   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.OleDb.OleDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   at ContactInformation.DataAccess.BaseDataAccess.ExecuteReader(DbCommand command) in C:\VS Projects\VS2010\Symlink\ContactInformation\ContactInformation.DataAccess\BaseDataAccess.cs:line 80
   at ContactInformation.DataAccess.PersonDataAccess.SearchPersons(Nullable`1 pin, Nullable`1 expectedTermDate, String loginName) in C:\VS Projects\VS2010\Symlink\ContactInformation\ContactInformation.DataAccess\PersonDataAccess.cs:line 58
   at ContactInformation.Operations.PersonOperations.SearchPersons(ISearch search) in C:\VS Projects\VS2010\Symlink\ContactInformation\ContactInformation.Operations\PersonOperations.cs:line 122
   at ContactInformation.Web.Default.DoSearch() in C:\VS Projects\VS2010\Symlink\ContactInformation\ContactInformation.Web\Default.aspx.cs:line 103
   at ContactInformation.Web.Default.btnSearch_Click(Object sender, EventArgs e) in C:\VS Projects\VS2010\Symlink\ContactInformation\ContactInformation.Web\Default.aspx.cs:line 95
   at ContactInformation.Web.UserControls.SearchControls.SearchBaseUserControl.btnSearch_Click(Object sender, EventArgs e) in C:\VS Projects\VS2010\Symlink\ContactInformation\ContactInformation.Web\UserControls\SearchControls\SearchBaseUserControl.ascx.cs:line 256
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Perhaps this is indicative of a problem with my code rather than my environment?

Jun 28, 2011 at 12:57 AM

Ah, in that case the issue is that command.ExecuteReader isn't in Enterprise Library, that's straight ADO.NET code. You could try to set up the source server for the .NET framework, but I'm pretty sure that you'll end up in native (C++) code pretty fast.

 

Jun 28, 2011 at 1:12 AM

That's what I thought.

And now I think I've found what the heck I've been doing wrong!!  It's meant to be

IDataReader Database.ExecuteReader(DbCommand command).

 

So, now I've changed the call, and I get a slightly more informative trace showing me that I'm going through the Enterprise Library, BUT, I'm still unable to step into the EntLib code.

Jun 28, 2011 at 1:38 AM

I've now disabled the "Enable Just My Code" option in the debug options, and that has now allowed me to pick the source file for the Enterprise Library.

Now, I'm curious why the call isn't adding a cursor parameter automatically.  

Should I start a new thread for this?

Jun 30, 2011 at 2:42 AM

I'm afraid this is more of debugging question rather than Enterprise Library. I suggest you post this to forums like Visual Studio Debugger Forum to get a better answer.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 30, 2011 at 3:52 AM

Thanks Noel.

I have now actually resolved all of the issues I was having by doing the following (in case someone else runs in to the same problem):

1) Changed all of the references for the EL assemblies to point to the GAC.
2) Disabled "Enable Just My Code" in the Debug opions
3) Added the Symbols location to the install directory containing the .pdb files
4) Removed file names from Solution Options --> Do not prompt for source files of the required files

This allowed me to successfully debug and step through the enterprise library code.  And with this, I was able locate the problem of why the DbCommandParameterCollection wasn't being populated correctly.

 

Thank you for all of your help and support.  I have learnt many things from this experience.