Can't attach to SPUCWorkerProcess - visual-studio-2010

The situation:
Working on a virtual machine for SharePoint development. I'd like to debug the sandbox solution that I have received from our contractor. Usually I manually attach to the process by going to the debug menu > Attach to Process... > then selecting the process from the list. This has worked in the past. Attaching to the process stopped working about the time that I reverted from Visual Studio 2012 back to 2010 (older projects had issues in 2010).
The problem:
Visual Studio gives an error, "Unable to attach to the process" when trying to attach to SPUCWorkProcess.exe that I need to debug a SharePoint sandbox solution.
Additional information:
I am able to attach to 2 other VM's are able to attach to the process
without issue (using same credentials).
An admin is able to attach to the process in this VM
Sandbox debugging IS turned on, even been restarted a few times from Central Admin.
Putting System.Diagnostics.Debugger.Launch()
in the code isn't hit/doesn't react
Attach to the process from the
task manager yields the message "Unable to attach to the crashing
process" ULS has a message for SPUCWorkerProcess "LogWMIData: Connect
Server failed: 0x80041003". Also noticed another error with OWSTIMER
"...Drives are running out of free space..." so could this be a
resource issue? the VM only has 4GB memory.
Given these details, I suspect that 1) available resources associated with my credentials are too small 2) something else is already attached to the process and crashing preventing me from attaching to it.

Solution was to provision a new virtual machine. My conclusion was that there is indeed a process running under my id (hence other people could attach to the process on the machine) preventing me from attaching to it again.
I was never able to figure out how to detach any process already attached to it, if there ever was one at all.
Hope this helps anyone else in some way. There appears to be very few solutions for "unable to attach to the process" that doesn't include forgetting to turn on the sandbox debugging.

Related

VS2015 Unable to connect remote debugger

I have VS2015 locally. Windows 2012 R2 server hosting an IIS8 test website.
I've put the updated DLL and PDB files in the BIN of the test website.
Step 1) On the remote server, I make sure the Remote Debugger is started.
Step 2) While in VS, I navigate to Debug => Attach to Process. Click "Find". Then click "Select"
This is when the error shows up "Unable to connect to 'address'. An operation is not legal in the current state."
I noticed the Qualifier port was changed, and is different than what shows in Step 1... so I try manually changing what's in the Qualifier to match.. but same issue.
I see the "Transport" is changed from Remote to WebKit. Not sure if this is a problem...
I figured it out. Instead of choosing Remote in the Transport dropdown. Select Default and then put your server in the textbox. Even though I am doing remote debugging, it solved the problem.
I got the same error while I tried to attached my solution with running localhost application hosted in iis. I just fixed it by selecting "Native code" in the "Attach to" field of the "Attach to Process" dialog.
In my scenario, a process running on a machine behind firewall had to be debugged. Usual steps did not help in discovering the machine or its process by selecting the Remote (No Authentication) option.
The following steps helped in remote debugging the process with firewalls on:
Run Remote Debugger on remote machine. The remote machine may have the firewall on. Leave Remote Debugger to run with Authentication Mode as Windows Authentication.
On the debugging machine, go to Debug->Attach to Process, and leave Default in Transport drop-down. Enter the IP of the remote machine for Qualifier and press Enter. This will ask to provide credentials to log into remote machine. Provide credentials. Processes running on the remote machine should now be listed under Available Processes
If the intended process on remote machine is not listed in Available Processes, check ""Show processes from all users"". This should show the process intended to be debugged.
If the break points are not loaded or hit when expected, go to Tools->Options->Debugging-> Uncheck Enable Just My Code. Break points should now hit.
Hope this helps.
Can a moderator add tags remote debugging and remote debugging with firewall to this post, and remove this line?

Windows service not stopping without restart?

I keep getting this error:
Error 1061: The service cannot accept control messages at this time
This happens when I attempt to stop the service installed using InstallUtil from this location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
I am attempting to debug the windows service in question. My problem is that everytime I attempt to introduce changes to the codebase, the computer "A physical machine - Dell Precision T3500" requires that I restart the entire machine to completely uninstall the service, before I do a reinstall.
I have looked at this Link and it is not helpful in my scenario as I would first have to stop the service to be able to gain full access to the location where my build is generated to.
Whilst the service is attempting to restart before I do the restart of PC, when I attempt to build the service from my code, I get this interesting error from the compiler:
Error 16 Unable to copy file
"obj\x86\Debug\X_WindowsService.exe" to
"bin\x86\Debug\X_WindowsService.exe". The process cannot
access the file 'bin\x86\Debug\X_WindowsService.exe' because
it is being used by another process. X_WindowsService
Because of the error above I also think this is why I am not able to use the SO solution from here.
Does anyone have a clever idea for me to go through to bypass having to restart the machine as I debug and make changes to my codebase?
I also had a look at this link from SO but it has no marked solution, I also tried one of the Microsoft forums for a solution but it too has no applicable solution as they recommend the restart which I am trying to avert.
I feel so silly after finding this solution. I should most certainly have used the KISS principle for this one.
Turns out, all I had to do was look for the service's process from task manager and simply end the task. After that a refresh to my services list shows the service status as blank, meaning it has completely stopped without a restart of the machine.

Remote debug a Windows service using VS2012

I've tried to find an answer to this before posting this question. I've got a windows service running on another machine. I've written the service in C# and the directory from which the service executable runs holds both executable and debug files (.pdb). I'm attempting to remote debug the service for the first time using VS 2012 Remote debugging. I'm able to attach to the service process successfully. However, as this is my first time I'm not sure what I can do next. I've clicked the pause button and that pauses the service on the line ServiceBase.Run(ServicesToRun) which isnt much use to me. The service has a timer which sets off every 30 seconds and will run the code in the timer event.
My question is ... is there a way of stepping through the code using the debugger in such a scenario.
Do I need to have some debug specific code already in my codebase so that when a debugger attaches it will take me to a place in the code from where i can step through the code?
Thanks,
Andrew.
There are several ways to debug your developed remote application or windows service. If you were in your machine(local) that would be simple to debug.
System.Diagnostics.Debugger.Launch();
But as you are in different machine it depends how your both Machines are connected. Which means you have some limitations on debugging remote application/services.
A Quick search gave me the following result that seemed helpful to me for you,
You can use Remote Debugging Monitor that visual studio use for connecting to remote device and debugging. You can have a clear instruction here on How to: Run the Remote Debugging Monitor.
There's another tool which lets you debug remote application's after a proper setup. But it has some limitations or conditions that you must abide by.
Here is the tool named Remote Tool, you can find a detailed setup process from MSDN here on How to: Set Up Remote Debugging.
It has been clearly quoted there about the prerequisites for using this tool. But still I'm rephrasing those again for quick reviewers.
Prerequisites to use Remote Tool for Visual Studio
To debug on a remote device:
The remote device and the Visual Studio computer must be connected over a network or connected directly through an Ethernet cable. Debugging over the internet is not supported.
The remote device must be running the Remote Tools for Visual Studio 2012.
You must be an administrator to install the remote tools on the remote device. To communicate with the remote tools, you must have user access to the remote device.
Feel free to share if you get to a better and working solution.
Thanks for your response. It reminded me to post my solution here for others like me.
The solution is simple (It always is once you know it).
Ensure that you are running the same code on the target machine as you have open in Visual Studio. It has to be the same assembly and version else the debugger will not hit your breakpoints. Ensure you have your breakpoints setup where you want the debugger to break execution. Then attach to the target machine process and wait for the timer to kick in and run the process where you breakpoint is set.
Hope this helps.
Andrew.

ClickOnce Publish fails and can't clean up

I am using ClickOnce to publish my application to a virtual server. Sometimes (and we don't know why) the Publishing of the application freezes. It will copy some of the files and then about 20 min later will copy one more and so one. Other times it will work fine.
The problem I have is that when I click Project -> Cancel Build, it will stop the publishing process but it keeps locks on my Debug/app.publish folder. These locks are not released even when I restart Visual Studio. If I don't remove those locks (usually by rebooting my machine), and I try to do another normal compile/build, my whole Visual Studio freezes and hangs my whole machine as it gets stuck on those files locks.
Does anyone know why this would happen? Does anyone know how to remove the file locks on the app.publish folder so I don't have to reboot and get on with my work?
I have had issues where the files it's replacing on the web server get locked or are in use and difficult to overwrite remotely. I usually from time to time have to remote in to the server to delete them and then try to publish again. I've seen this on load balancing servers that replicate and the process has caused issues for me.

Confused about remote debugging in Visual Studio 2010

I have a console app that I am trying to debug using remote debugger.
Clearly it seems you need to first run the application on the remote server, then attach to process.
My question is, whats the preferred method to catch the code at the start of execution, so it won't run away by the time you've managed to hookup the debugger.
Is there an industry standard best practice way to hook in and pause execution at a certain point till the debugger is attached?
There is a way to launch the remote app from Visual Studio.
Go to the Debug tab in project properties window.
Select Start external program and specify the exe path. (e.g. C:\MyTestApp\MyTestApp.exe)
Check Use remote machine and enter the name of the remote machine.
Detailed explanation here.
I couldn't think of a way to attach to a process in remote machine before the process starts. But , have you considered using Intellitrace to see the events and state of your program?
There is a way to attach a debugger to a Application automatically when the application launches. But I am not sure if it would work on remote debugging.
Similarly the System.Diagnostics.Debugger.Launch() would launch a process and start a Debugger attached to it. Again it doesn't support Remote launching and debugging.

Resources