Recently I tried to install a webpart through wspbuilder utility to the Sharepoint Site. I have created, built and deployed a project to the 12 hive. After that installed the solution through Cental Administration Site and activated in the site collection.
I just wonder how can I debug the complex feature/solution ? Because both processes (build-deploy and activate) totally independent, how can I attach a process with the worker process ?
In the WSPBuilder context menu there is an option "Attach to IIS worker process". As long as the app is loaded (generally means that you have accessed a page in the SharePoint site before trying to attach) and the code deployed in SharePoint is the same as the code you have in Visual Studio, you should be able to set breakpoints and step through the code.
First, you need to open up your browser and navigate to the SharePoint website in question. Then, In Visual Studio, go to Debug --> Attach to Process, and find the w3wp.exe process associated with the Sharepoint website that you want to debug. Click it (the process) and then click the Attach button. You should now be able to debug any activities associated with your SharePoint feature.
Sometimes it is a bit of a pain to figure out which w3wp process to attach to. Try adding the following to your code to break into the debugger:
System.Diagnostics.Debugger.Break();
System.Diagnostics.Debugger.Break()
Like Muhimbi suggested, this is actually very useful in certain cases. Say you want to debug custom code (e.g. feature_deactivating event) when it might be invoked with stsadm and not the browser. (for e.g. you will have to use stsadm for feature deactivation when feature is hidden in UI).When using stsadm you cannot attach to cmd.exe because that's a separate process. If you type the command and hit enter and then find its id of stsadm.exe process to attach to, its too late. In situations like these, the command above is the easist and best solution
I tried the steps as mentioned here
go to Debug --> Attach to Process, and find the w3wp.exe process associated with the Sharepoint website that you want to debug
But I get "Breakpoints will not be hit, no symbols have currently been loaded for this document". Should I have to register the custom deployed solution dll using GACUTIL ? Should I have to copy the PDB files at any particular location ?
What am I missing here ?
Related
I'm using VS 2013 and a SP 2013 farm solution which contains a workflow.
I'm desperately trying to debug my workflow to gain some inside information.
This is what I tried so far:
First of all I set a breakpoint on a GetCurrentItemId Activity
Next I hit F5.
The workflow test host console opens up and the web browser showing my sharepoint site
Next I navigate to my list and start the workflow on any (single) item
The workflow test console stays all black - not a single piece of information to find here
The workflow's internal status changes to "Completed".
...obviously my breakpoint has not been hit. WHY? :(
Solved
Reinstalling VS 2013 did in fact help.
From what I can see you have been starting your workflow in debug mode and trying to debug in on a list event.
Instead of doing that try adding your breakpoints (I always add breakpoint in the first scope) and then go to
Debug -> Attach to Process and look for Microsoft.Workflow.ServiceHost.exe and click attach.
Before doing any work with that list items to trigger the workflow verify that your breakpoints are active - if not try retracting your solution and redeploy, then one more time try attaching it to the WF service.
Hope it helps.
When you attach to the process Microsoft.Workflow.ServiceHost.exe you must select the type of code you will attach to. Just select Workflow and you´ll be able to see the workflow context variables.
I've been following this guide to debug a Windows Service application.
Basically, I need to attach the Visual Studio debugger to the process started after installing the Windows Service that has been developed. However, VS doesn't allow me attach the debugger to this process as shown in the following picture:
How can I attach the debugger to this process? If I clicked on any of the other processes the Attach button becomes enabled.
Any help would be greatly appreciated
check the checkbox Show processes from all users, then you will see AutomatedReports.exe. Attach that (not AutomatedReports.vshost.exe)
vshost is a host process to help with the debugging. More info on this MSDN Link
Also you need to place the following line in your service code where you want to hit the break point.
System.Diagnostics.Debugger.Break();
The service is probably running on a separate user account. Check the "Show processes from all users" checkbox and attach the debugger to AutomatedReports.exe process.
Also make sure that you are running a Debug build of the service, otherwise, you won't be able to debug a lot.
Have you tried to change the type of the code you are debugging?
Click on "Select ..."
Select "Debug these code types"
You can then select Types like: “Managed (v4.0…)"
I have a VS2010 running on a WTS machine (Windows2008).
I'm trying to attach the debugger into a process. The process is running a WPF client.
The process is presented in the attach to process dialog, but grayed out and the attach button is disabled.
I read through the discussions, and confirmed managed code is enabled for debugger, with no luck. Here are two screenshots representing the current situation (in the first image, the process I'm trying to debug is marked in blue - please note I'm running as admin):
snapshot goes here - but was removed by stack overflow...
After trying the automatic code type selection, I tried the manual way, with no luck. Here is the screenshot:
snapshot goes here - but was removed by stack overflow...
Any help would be appreciated.
Thanks,
Busi
Perhaps you are already attached to the process? Did start debugging before attaching to the process?
Found another cause/solution to this problem, select the 'Show processes from all users' and 'Show processes in all sessions' check boxes and I got two instances of my service, one greyed out (which was always visible) and another I could attach to. hth :).
I ran into the same issue with my windows service.
I could not attach to a running windows service that I built.
My solution has multiple projects with the windows service as the startup project.
I found out that my problem is caused by having the startup project is the same as the windows service.
To solve my problem, I just set a different project as the StartUp Project.
I'm not certain, but there may be a debugger already attached to the process, and that's why Visual Studio won't let you attach it. Are you certain that you're not running the application already in debug mode or do you have another VS instance running?
If you are trying to attach a web service or web app (w3wp.exe) then, try resetting the iis (iisreset). It worked for me.
I tried the following steps in order to debug a particular custom timer ( installed and activated):
Copied the both .dll and .pdb files in the GAC.
Restarted the timer services.
Attached both w3wp and OWSTimer.exe processes.
But the debugging is still not taking place. The debugger placed is empty circle which displays this message:
The breakpoint will not currently be hit. No symbols have been loaded for this document.
The OWSTimer is shown in a diff username. Does It needs to be run from my account?
Why debugging is not working?
Debugging Timer Jobs can be hard... The steps you took sound about right, but you can also do some more:
Timer Jobs run in OWSTimer.exe - you only need to attach to that one
Restart the timer service. For good measure throw in a restart, deploy, restart, iisreset ;-)
Did you do a DEBUG Build or RELEASE build?
Make sure you actually RUN your timer job (as in trigger it)
If your breakpoints are still not hit, do something ugly: use Debugger.Launch() or Debugger.Break() in your code or an assertion which will always fails: System.Diagnostics.Trace.Assert(false);
And then there is MSDN for the rescue.
Try loading debug symbols manually and see what it says:
To display the Modules window in break mode or in run mod
On the Debug menu, choose Windows, and then click Modules.
By default, the Modules window sorts modules by load order. However,
you can choose to sort by any column.
In the Modules window, you can see which modules have debugging
symbols loaded. This information appears in the Symbol Status column.
If the status says Skipped loading Cannot find or open the PDB file,
or Loading disabled by include/exclude setting, you can direct the
debugger to download symbols from the Microsoft public symbol servers
or to load symbols from a symbol directory on your computer. For more
information, see How to: Use a Symbol Server and How to: Specify
Symbol Locations and Loading Behavior.
To load symbols manually
In the Modules window, right-click a module for which symbols have not
loaded.
Point to Load Symbols From and then click Microsoft Symbol Servers or
Symbol Path.
copied from MSDN
You can also try to delete Visual Studio cache just to be sure (from command prompt):
del /Q %LOCALAPPDATA%\Microsoft\WebsiteCache
del /Q %LOCALAPPDATA%\Temp\VWDWebCache
del /Q %LOCALAPPDATA%\Microsoft\Team Foundation\1.0\Cache
Just adding to moontear's post.
I had the same loading debug symbols issue until I added in this code to the first line of my Execute method.
public override void Execute(Guid contentDbId)
{
// If in debug mode, trigger a false assertion to give time
// to attach the debugger to the OWSTIMER.EXE process.
#if (DEBUG)
System.Diagnostics.Trace.Assert(false);
#endif
...
Check to make sure your regional settings are correct - append /_layouts/15/regionalsetng.aspx to the CA URL. If you have the wrong time zone, your job may be scheduled for a time in the past. This has hung me up more than once. If this is the case, set the correct time zone (using the url above), stop and start the timer service (either services tool or open command line - net stop sptimerv4 then net start sptimerv4). Then attach to OWSTIMER and debug.
On the Start menu, point to Administrative Tools, and then click Services.
In the Services window, make sure the SharePoint 2010 Timer service is started.
Open the Visual Studio 2010 project that contains your timer job.
Set a breakpoint in the Execute method of your job definition class.
On the Debug menu, click Attach to Process.
In the Attach to Process dialog box, c
If the Attach Security Warning dialog box is displayed, click Attach.
In the SharePoint Central Administration Web site, click Monitoring and then click Review job definitions.
Click the name of your job, and then click Run Now on the Edit Timer Job page.
Verify that the Visual Studio 2010 debugger stops execution on your breakpoint.lick OWSTIMER.EXE, and then click Attach.
Is there any plug-in for Visual Studio that can display the associated Application Pool name for those w3wp processes when debugging them with "Attach to Process..." ?
Usually I have to do following steps before debugging:
c:> \Windows\system32\inetsrv\appcmd list wps
then I get the process id for the Application Pool I want to debug, and then attach it in the Attach to Process window.
I feel it will be very pleasure if there's a plug in can do this automatically, but didn't find any such thing after Googled.
You can use a macro—see my answer to a related question. I am practically always attaching to one of a few specific Application Pools, so I’ve made buttons to attach to those specifically in one click. If you really want to choose from a dynamic list each time you’ll just have to build that dialog, but you can lift from my macro code to get the list.