[{"data":1,"prerenderedAt":367},["ShallowReactive",2],{"article-sharepoint-wss-3-0-tips-debugging":3},{"article":4,"tags":191,"previous":206,"next":282},{"id":5,"title":6,"author":7,"body":8,"createdAt":180,"description":181,"extension":182,"img":181,"meta":183,"navigation":184,"path":185,"seo":186,"stem":187,"tags":188,"updatedAt":180,"__hash__":190},"articles\u002Farticles\u002Fsharepoint-wss-3-0-tips-debugging.md","Sharepoint WSS 3 Tips Debugging","[object Object]",{"type":9,"value":10,"toc":178},"minimark",[11,15,28,31,38,41,44,78,160,171,174],[12,13,14],"p",{},"Getting the w3wp.exe ProcessID for Attach to Process  ",[16,17,18,19,23,24,27],"blockquote",{},"   ",[20,21,22],"strong",{},"Open command prompt and type iisapp.vbs","     ",[20,25,26],{},"Attach a debugger to your code"," ",[20,29,30],{},"The code you are using to debug must be exactly the same as the executing assembly",[12,32,33,34,37],{},"This often catches people out in SharePoint development as the assembly SharePoint is using is often in a different location than the default build directory (i.e. in the bin directory in IIS or in the GAC). You may want to include a post build script to copy your assembly to the correct location to help automate this process. Also be careful when debugging assemblies that are in the GAC as you may need to do an iisreset to ensure ASP.NET uses the latest version of your assembly.       *        ",[20,35,36],{},"The .pdb file needs to be in the same directory as the assembly to see line numbers",".",[12,39,40],{},"This is easy if you are using the bin directory of the website (recommended when developing), but you cannot copy these files directly into the GAC. You can get around this with the following steps:                  * Map a network drive to the GAC (C:\\WINDOWS\\assembly) folder.",[12,42,43],{},"This allows you to see the actual folder structure and copy files into the folders as they appear on disk (opposed to the shell that is shown when browsing directly).           * Copy the .pdb file into your assembly folder in the GAC_MSIL subfolder so that it sits next to the assembly dll.",[45,46,47],"ul",{},[48,49,50,53,54,60,61,60,70,60,75],"li",{},[20,51,52],{},"Activate features through the UI if you want to debug feature receivers",". If you use the stsadm command line tool to automate feature deployment the w3wp process will be recycled so any debuggers will be detached. Activating these through the central admin or the site features page will ensure the w3wp process is running.       ",[16,55,56,57,27],{},"    ",[20,58,59],{},"Use Debug and Trace statements","  ",[16,62,63,64,69],{},"   System.Diagnostics.Debug and Trace statements are another great way of tracking down errors in your code. As Debug calls are removed from release builds, these can be used extensively to help track down errors in development. To view these you can use tools such as\n",[65,66,68],"a",{"href":67},"http:\u002F\u002Fwww.microsoft.com\u002Ftechnet\u002Fsysinternals\u002Futilities\u002Fdebugview.mspx","DebugView"," to view messages on local or remote machines ",[16,71,18,72,27],{},[20,73,74],{},"Use Try-Catch statements",[16,76,77],{},"   As with standard ASP.NET applications, Try-Catch statements can help catch and log error messages that occur in your code. This can be combined with Debug and Trace statements to view or log errors, or display meaningful messages to the user.\nFor example in a web control you might do the following:",[79,80,85],"pre",{"className":81,"code":82,"language":83,"meta":84,"style":84},"language-csharp shiki shiki-themes github-light github-dark","protected override void Render(HtmlTextWriter writer)      \n{       \n    try       \n    {       \n        \u002F\u002F code that might cause an error       \n    }       \n    catch       \n    {       \n        Trace.Write(ex);       \n        writer.Write(ex.Message);       \n    }       \n} \n","csharp","",[86,87,88,96,102,108,114,120,126,132,137,143,149,154],"code",{"__ignoreMap":84},[89,90,93],"span",{"class":91,"line":92},"line",1,[89,94,95],{},"protected override void Render(HtmlTextWriter writer)      \n",[89,97,99],{"class":91,"line":98},2,[89,100,101],{},"{       \n",[89,103,105],{"class":91,"line":104},3,[89,106,107],{},"    try       \n",[89,109,111],{"class":91,"line":110},4,[89,112,113],{},"    {       \n",[89,115,117],{"class":91,"line":116},5,[89,118,119],{},"        \u002F\u002F code that might cause an error       \n",[89,121,123],{"class":91,"line":122},6,[89,124,125],{},"    }       \n",[89,127,129],{"class":91,"line":128},7,[89,130,131],{},"    catch       \n",[89,133,135],{"class":91,"line":134},8,[89,136,113],{},[89,138,140],{"class":91,"line":139},9,[89,141,142],{},"        Trace.Write(ex);       \n",[89,144,146],{"class":91,"line":145},10,[89,147,148],{},"        writer.Write(ex.Message);       \n",[89,150,152],{"class":91,"line":151},11,[89,153,125],{},[89,155,157],{"class":91,"line":156},12,[89,158,159],{},"}\n",[12,161,162,165,166,170],{},[20,163,164],{},"View the SharePoint Logs","\nThe raw SharePoint log files are extremely cluttered and hard to use but there is an alternative. The ",[65,167,169],{"href":168},"http:\u002F\u002Fwww.codeplex.com\u002Ffeatures\u002FRelease\u002FProjectReleases.aspx?ReleaseId=2502","LogViewer feature on CodePlex"," lets you easily select a log file and view a filtered display of the items you are interested in.    ",[16,172,173],{},"   You can also tweak the information that is written to the SharePoint logs via the Diagnostic Logging link under Logging and Reporting in the operations section of Central Administration.",[175,176,177],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":84,"searchDepth":98,"depth":98,"links":179},[],"2015-04-20T08:07:18.2100000-04:00",null,"md",{},true,"\u002Farticles\u002Fsharepoint-wss-3-0-tips-debugging",{"title":6,"description":181},"articles\u002Fsharepoint-wss-3-0-tips-debugging",[189],"sharepoint","a4E2rqcS5lz36oL5AbpTT_W92wj7pXV4YGKqJglbkn0",[192],{"id":193,"title":194,"body":195,"description":199,"extension":182,"img":200,"meta":201,"name":189,"navigation":184,"path":202,"seo":203,"stem":204,"__hash__":205},"tags\u002Ftags\u002Fsharepoint.md","Sharepoint",{"type":9,"value":196,"toc":197},[],{"title":84,"searchDepth":98,"depth":98,"links":198},[],"Microsoft SharePoint","https:\u002F\u002Fimages.unsplash.com\u002Fphoto-1598313183973-4effcded8d5e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=675&q=80",{},"\u002Ftags\u002Fsharepoint",{"description":199},"tags\u002Fsharepoint","1yMA-SLjOHmy0x6_m2U0v9b58OVV2Jg1i0vhgXavZ7M",{"id":207,"title":208,"author":7,"body":209,"createdAt":274,"description":275,"extension":182,"img":181,"meta":276,"navigation":184,"path":277,"seo":278,"stem":279,"tags":280,"updatedAt":274,"__hash__":281},"articles\u002Farticles\u002Fsharepoint-web-part-deployment.md","Sharepoint Web Part Deployment",{"type":9,"value":210,"toc":272},[211,214,249,252],[12,212,213],{},"If when using Windows Sharepoint Services you are unable to retract or execute jobs seen through the management interface using the following commands can help to manually list and remove and redeploy solutions.",[12,215,216,217,220,223,224,226,229,230,232,235,236,238,243,245,248],{},"To see a list of all solutions on the server",[218,219],"br",{},[20,221,222],{},"stsadm.exe -o enumsolutions","  To see a list of all deployments",[218,225],{},[20,227,228],{},"stsadm.exe -o enumdployments","  To cancel a deployment",[218,231],{},[20,233,234],{},"stsadm.exe -o canceldeployment -id {guid}","  To execute scheduled jobs",[218,237],{},[20,239,240,241],{},"stsadm.exe -o execadmsvcjobs",[218,242],{},[218,244],{},[20,246,247],{},"Error: \"the solution cannot be removed when a job is scheduled or is running\" \u003C ","use the above commands to execute jobs that are scheduled",[12,250,251],{},"I am using something like the following when removing and deploying web parts (notice the execadmsvcjobs)",[12,253,254,255,260,261,263,264,266,267,269,270,260],{},"stsadm.exe -o retractsolution -name webPart.wsp -immediate -url {",[65,256,259],{"rel":257},[258],"nofollow","http:\u002F\u002F...} ","\nstsadm.exe -o execadmsvcjobs",[218,262],{},"\nstsadm.exe -o deletesolution -name webPart.wsp -override",[218,265],{},"\nstsadm.exe -o addsolution -filename webPart.wsp",[218,268],{},"\nstsadm.exe -o deploysolution -name webPart.wsp -immediate -allowgacdeployment -url {http:\u002F\u002F...} -force",[218,271],{},{"title":84,"searchDepth":98,"depth":98,"links":273},[],"2015-04-20T08:07:18.3200000-04:00","Learn how to deploy web parts.",{},"\u002Farticles\u002Fsharepoint-web-part-deployment",{"title":208,"description":275},"articles\u002Fsharepoint-web-part-deployment",[189],"o0IIXKtNlmzSimnQm8juIvIaJ1WCP7U-9Nnxq9lvtrA",{"id":283,"title":284,"author":7,"body":285,"createdAt":358,"description":359,"extension":182,"img":181,"meta":360,"navigation":184,"path":361,"seo":362,"stem":363,"tags":364,"updatedAt":358,"__hash__":366},"articles\u002Farticles\u002Fsql-execution-enterprise-manager-qa-vs-net-execution.md","SQL Execution (Enterprise Manager-QA) VS. .NET Execution",{"type":9,"value":286,"toc":356},[287,309,330],[12,288,289,290,292,293,295,296,298,299,301,302,304,305,308],{},"I have been chasing an issue for quite a while where the query would timeout when executed from an ASP.NET interface.  If I ran that exact same query through Query Analyzer the results would be returned in less than 2 seconds.    I have for a while been struggling with why it is different between those two interfaces.  I thought about connection pooling issues, command time outs and connection timeouts and was focused on that for a while.  Even after extending those values from the default the query would still time out.  It was often I would see an exception similar to   ---------------------------  SQL Exception Information:",[218,291],{},"\nErrorId: -2",[218,294],{},"\nMessage: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.",[218,297],{},"\nLine Number: 0",[218,300],{},"\nProcedure:",[218,303],{},"\n---------------------------  To put this post in the proper context think about one of your application search stored procedures.  The interface shows a dozen or more optional textboxes for user entry to narrow down the results.  The stored procedure in this case often has many parameters that could be used with the actual query.  This is the case for the query that I am discussing herein.  When you execute a stored procedure for the first time the query processor constructs a query plan based on the the state of the statistics and the input parameters.  So, the query plan is created upon first execution and is cached in case some other invocation of the same stored procedure comes along before the cache is cleared.  So, when executing through the web interface SQL Server is using the same execution plan that was created by the prior user.  This can look significantly different between users and what parameters they provide before they run the search.  So, to have SQL Server generate a new query plan upon each execution the \"",[20,306,307],{},"WITH RECOMPILE","\" can be used.  By adding this parameter SQL Server regardless of the parameters passed in it will create a new optimal plan.  ",[16,310,311,312,314,315,317,318,320,321,323,324,326,327],{},"   i.e.",[218,313],{},"\nCreate Procedure dbo.GetCustomers",[218,316],{},"\n            @LastName varchar(200),",[218,319],{},"\n            @FirstName varchar(200),",[218,322],{},"\n            .... \nWITH RECOMPILE AS",[218,325],{},"\n  BEGIN",[12,328,329],{},"  END ",[16,331,332,333,314,335,317,337,320,339,341,342,326,344,346,347,349,350,352,353,355],{},"   i.e. SQL 2005 option",[218,334],{},[218,336],{},[218,338],{},[218,340],{},"\n            .... \nAS",[218,343],{},[218,345],{},"\n      Query 1",[218,348],{},"\n      Query 2 OPTION(RECOMPILE)",[218,351],{},"\n      Query 3 OPTION(RECOMPILE)",[218,354],{},"\n      Query 4 \n  END ",{"title":84,"searchDepth":98,"depth":98,"links":357},[],"2015-04-20T08:07:18.1100000-04:00","I have been chasing an issue for quite a while where the query would timeout when executed from an ASP.NET interface.  If I ran that exact same query through Query Analyzer the results would be returned in less than 2 seconds.    I have for a while been struggling with why it is different between those two interfaces.  I thought about connection pooling issues, command time outs and connection timeouts and was focused on that for a while.  Even after extending those values from the default the query would still time out.  It was often I would see an exception similar to   ---------------------------  SQL Exception Information:\nErrorId: -2\nMessage: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.\nLine Number: 0\nProcedure:\n---------------------------  To put this post in the proper context think about one of your application search stored procedures.  The interface shows a dozen or more optional textboxes for user entry to narrow down the results.  The stored procedure in this case often has many parameters that could be used with the actual query.  This is the case for the query that I am discussing herein.  When you execute a stored procedure for the first time the query processor constructs a query plan based on the the state of the statistics and the input parameters.  So, the query plan is created upon first execution and is cached in case some other invocation of the same stored procedure comes along before the cache is cleared.  So, when executing through the web interface SQL Server is using the same execution plan that was created by the prior user.  This can look significantly different between users and what parameters they provide before they run the search.  So, to have SQL Server generate a new query plan upon each execution the \"WITH RECOMPILE\" can be used.  By adding this parameter SQL Server regardless of the parameters passed in it will create a new optimal plan.  ",{},"\u002Farticles\u002Fsql-execution-enterprise-manager-qa-vs-net-execution",{"title":284,"description":359},"articles\u002Fsql-execution-enterprise-manager-qa-vs-net-execution",[365],"sqlserver","B2ug2YjmetZNfsPVc-Gc3dmawycSNaf-YqYAdz1IpqQ",1781574766337]