Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Unable to debug a web part (User Control file - .ascx.cs)

  Asked By: Rickie    Date: May 17    Category: Sharepoint    Views: 6816

1) I created a Class Library with a class and given path of User control,
overridden CreateChildControls(), RenderContents() methods, inherited WebPart
Created User control in a separate web site.
2) I copied the UserControl files (.ascx and .ascx.cs) and pasted these files in
C:\Inetpub\wwwroot\wss\VirtualDirectories\8081\UserControls folder
3) Copied the dll and pasted in
C:\Inetpub\wwwroot\wss\VirtualDirectories\8081\bin folder and assembly folder
4) Added <safeControl> tag in web.config file located at
5) Kept breakpoints to the class in the class library and attached worker
process w3wp.exe.
6) Loaded the web part in the webpart gallary and clicked on the link for
preview, it has taken to the class and i am able to do debug class file, but not
able to debug usercontrol file.
I need to do debug .ascx.cs file, how can I do it. Am I doing in the correct



2 Answers Found

Answer #1    Answered By: Amanda Lewis     Answered On: May 17

I'm pretty sure to debug  the ASCX file  you are going to need the source
files added  to the project you are debugging from. It sounds like you
are trying to debug the ASCX code beside sheet from inside the Webpart
wrapper project. Also, DLLs should be deployed to either the GAC or Bin
folder, but not both. If you deploy to the GAC you have the added
problem of making the PDB symbol file available for debugging since that
can't be added to the GAC directly.

Answer #2    Answered By: Cassie Snyder     Answered On: May 17

Instead of creating a class  Library, create a new web  Application project
(NOT a new web site) instead. Then move all your class library
application objects into this new application.

If you create a web application project instead of a class library, Visual
Studio will more easily recognize the .ascx control. From your web part's
CreateChildControls(), you'll also be able to directly cast your .ascx
control class (instead of casting the generic UserControl).

This is one of the very few cicumstances where I create something other
than a Class Library.

Didn't find what you were looking for? Find more on Unable to debug a web part (User Control file - .ascx.cs) Or get search suggestion and latest updates.