Hot answers tagged debugging
9
F5 debugging is pretty cool, but for small and not complicated projects. You know, that by pressing F5 your solution will be deployed again, including all steps - add solution, install solution, activate features. And it often takes really long time.
There is a couple of extensions for visual studio that makes your life easier. As for me, I use CKS DEV ...
5
My biggest issue with testing timer jobs was getting the job to start so that I could debug it. It seems like I when I reset the timer service whenever I deployed new code and when the service restarted, even though I had my job to run every minute, sometimes it would take up to an hour for it to "catch up" and get around to running my timer job.
I think ...
4
This sounds like you're studying for TS: SharePoint 2010 Application Development 70-573.
The part that says what's included are actually practices any development in SharePoint, not specific to Web Parts.
It seems strange to me though, that their list doesn't include the most powerful debugging utility available to a developer - Attaching to w3wp and ...
4
If you're getting this error on sharepoint/wss specific pages, you also have to add following fragment to your web.config to view the stacktrace:
<SharePoint>
<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
<PageParserPaths>
...
4
I would check the ULS logs with a tool like the ULS Viewer.
Start a trace, load the page again and check the viewer. It may reveal more details about what's happening to cause the problem.
Here's a link: http://archive.msdn.microsoft.com/ULSViewer
4
You'd have to use something like .NET Reflector and its Visual Studio plugin in order to actually step through the code in the debugger.
With something like ILSpy you can take a look at the code, but not step through it, which may well be enough to discover what's going wrong without spending money.
4
You best chance is to try at least four things while debugging:
Use logging library "SharePoint Sandbox Logging" to log errors on
feature activation, as you probably know logging capabilities on
Sandbox are limited.
Have Correlation Id with your error? contact Microsoft support
Review SharePoint logs for on-premises Sandbox to check for any
errors, ...
3
When the piece you are debugging can run from a sandboxed solution, F5 debugging is much faster. For one thing, you don't have to recycle the application pool. To me, that feels much more like the typical plain asp.net debugging situation.
Not every solution can fit in the sandbox and benefit from this speed up. Sometimes, the incompatability with the ...
3
I am not pretty sure how you are debugging your SharePoint portals right now. But I would suggest you look at the Visual Studio 2010 extensions and different techniques that make debugging life easier. Please go through this post where all these are consolidated at one go.
...
3
This is why i only work from VM's, they're easily replaced, and my host OS (Server 2008R2) remains clean and fast. I have a whole domain running in multiple VM's and only have the bare minimum installed directly on my laptop (Only Office basically). Whenever a new version of a product is released, i create a new VM and test / try it in there. If it breaks, ...
3
The problem is that in SharePoint, you have no idea how many web servers is running your site, and therefore you've no idea how many web.config's could be running (not you in particular, but in general, SharePoint can handle dozens of web front end servers). In order manage changes to the web.config file, the object model is design such that any and all ...
3
You can use
System.Diagnostics.Debugger.Launch();
to attach a debugger (Visual Studio) instead of attaching the timer job in VS.
Also i tend to use DebugView alot to just write out asserts or messages like
System.Diagnostics.WriteLine("sometext","MYCATEGORY");
Another tip for testing is to encapsulate the logic in its own class. Then you can test ...
3
You have two options:
Catch all errors in your web part and then log them to ULS, show in hidden div, ...
Develop you web part in a Sandboxed solution, then SharePoint will take care of protecting the rest of the page
To elaborate on the first. It can be implemented using this pattern:
Add a string variable errorMessage
string errorMessage;
Write ...
2
A couple of small things you have probably already considered.
Stop and restart the Timer service as part of the pre-build event to release any of your solution's GAC dlls.
Rather than attaching to the process using the debugger I prefer to use System.Diagnostics.Debugger.Break();
For other SharePoint related guidelines, check out our free SharePoint ...
2
If you are using VS2010 to deploy the feature, try changing the Active Deployment Configuration in the Project Properties\SharePoint tab to "No Activation".
When you run the application with debugging (F5), it will deploy the package and activate it before the debugger attaches to the process.
Turning off automatic activation will allow you to attach to ...
2
As both Anders and Steve have pointed out, write the main processing of your timer job in a separate Class Library. For debugging "wrap" a Console App around it, and when you're happy wrap it in a timer job. If at a later point you want to debug, you use your Console App again - F5 and there you go.
On a related note, check out SharePoint Layered ...
2
Are your symbols available? You might need to copy the PDB file to the GAC. Here are some articles on the subject:
http://blogs.msdn.com/b/markarend/archive/2008/09/09/debugging-web-parts-and-other-sharepoint-custom-code.aspx
You also might want to try inserting a line of code that pops up a window asking if you want to debug it. From ...
2
According to this post How to debug Feature Receiver you can add this line of code to the method you are trying to debug:
System.Diagnostics.Debugger.Launch();
2
I have seen this behavior before when IIS is not cycled after VS builds and deploys to the GAC. In those cases, it is using a cached copy of the code and thus the breakpoints do not line up. An occasional IISReset will flush this through.
The other thing to try is manually attach to ALL W3WP.exe processes and see if it hits your breakpoints then. If it ...
1
Try the following:
Deploy the solution as Farm solution
Change the scope as "Site" from "Web"
Rebuild the solution file and deploy it agagin.
Finally press F5 and put the break point in the code where you want.
Please let me know if the above doesn't work.
1
I have been able to create a workaround, although the reason for the failure is still unknown.
I suspected that the Sandboxed code service was acting up because my code performs a lot of requests in a short amount of time (it has to, since it creates a site from scratch). I still don't have an explanation why it works on the server installation, the sandbox ...
1
There are a few things I'd suggest:
CKS:Dev - as above. It's great. It simplifies attaching to your W3WP, OWSTimer service, and UserCode service (for debugging sandbox solutions).
Consider writing a Diagnostics service so you can write to the ULS logs in a structured way.
Use SPMonitoredScopes and SPCriticalTraceCounters. They can be useful, though I tend ...
1
The config "template" files that are merged to create web.config files in the web root when web applications are provisioned are contained in the CONFIG directory in the SharePoint root (not LAYOUTS). The LAYOUTS folder in the SharePoint root is used by the _layouts virtual directory, i.e. application pages.
As well as making changes programmatically, you ...
1
Couple of extra suggestions:
I assume you are debugging locally on the machine that is running central admin. If there are multiple servers in the farm, just make sure you are on the server that is actually running central admin.
Try killing the vssphost4 process, and then restart visual studio. I have found that the method VS (which is 32 bit) uses to ...
1
Based on what you have said, it sounds as though something is wrong. The only recommendation I would add for your setup is to get an SSD. But it should work acceptably on your system as it stands. I run SharePoint Foundation on a much lower spec. laptop, although admittedly I am using local accounts rather than running AD.
Don't forget that a 10-20 second ...
1
The error can relate to a lot of things:
File (ASCX) is not valid: Create
a new visual webpart, then compare the 2 ascx files, a small typo like a
< or > to much can break a file
Did you change any project settings: Target framework (can't be 4.0), Deployment type (Sandbox or Farm)
Server ran out of memory and stopped compiling (Check the eventlogs)
...
1
The full range of things to do is listed on this page:
http://blogs.prexens.com/Lists/Posts/Post.aspx?List=7a299699-f8da-4559-920c-bda481608691&ID=8
You need to also set CallStack to true in the SafeMode node to see the CallStack you require.
1
There are some skills around debugging JavaScript that you'll need to learn. Firebug and the IE Developer Tools (or equivalent in Chrome, etc.) are the tools, but you'll need to learn how to use them well. There's not really an "answer" to your question.
Generally, you'll have syntax errors like missing commas, brackets, parentheses, or semicolons. That's ...
1
Hi
did you copy the pdb files to the GAC-directory where your assembly lies?
To do this, use TotalCommander or CommandPrompt to navigate to
c:\windows\assembly\GAC_MSIL[Name of your assemlby][Version]\
there should be the .dll.
Now copy the according .pdb from your debug build, reset IIS (or recycle AppPool), open a page of your site (to restart w3wp), ...
Only top voted, non community-wiki answers of a minimum length are eligible
