Issues debugging WCF Service - c#

So I'm having an intense amount of trouble trying to debug a wcf service, and could use some help. The service I'm writing is in C#, Visual Studio 2010, and is part of an existing service my company has in one of our client's projects. I'm using WCFTestClient to connect to the service when i debug it locally. Whenever I first open up visual studio and debug the service in question it works fine, but if I make changes to the code and need to rebuild, I'm getting the following error:
Unable to copy file "obj\Debug\Application.DataAccess.dll" to
"bin\Debug\Application.DataAccess.dll". The requested operation cannot
be performed on a file with a user-mapped section open.
The only way I've been able to work around this issue is to close visual studio and reopen it, which is rather time consuming and annoying to do every time I make a change. I've tried cleaning the solution and rebuilding, but I get the same error. I've even opened up Process Explorer to try and find what's using the dll, but the only thing is FxCopCmd.exe which is part of visual studio.
Does anyone have a better way of debugging wcf services locally, or have an idea of how to prevent or resolve the above error? Any help is greatly appreciated, thanks.

I was having the same problem (FxCopCmd.exe locking some DLLs) and I found out that people using this extension "Visual Studio Achievements For VS2010" were also experiencing similar issues (see the comments on this page).
Removing this extension from Visual Studio solved the problem for me.

Go to the Windows folder of solution location and delete all bin / obj / debug DLL's manually rather than cleaning the solution. Should work then (had same issue at my end when I took latest of existing WCF from TFS and while building it gave me error)

As stated here: The requested operation cannot be performed error when compiling an XNA project
Closing project settings file solved the problem for me.

Related

Visual Studio 2015 and uwp development - User-Mapped section error and CopyWin32Resources error

Continuing with some UWP development and 2 things keep happening with visual studio and I can't work out if its a VS2015 bug, the fact that I am deploying to a windows Mobile 10 device or something else.
Randomly when I try to build or deploy to my device I get either.
Could not copy "obj\ARM\Debug\MyApp.exe" to "bin\ARM\Debug\MyApp.exe". Exceeded retry count of 10. Failed.
Unable to copy file "obj\ARM\Debug\MyApp.exe" to "bin\ARM\Debug\MyApp.exe". The requested operation cannot be performed on a file with a user-mapped section open.
or I get
CopyWin32Resources failed with exit code 500
Seems to be random and I can't nail down what is causing either. Googling didn't really help. Some said Anti-virus but disabling mine did nothing. Some said it was something to do with Visual Studio Achievements Extension but I don't have it installed.
Anyone know the cause or a fix? Making development difficult when I can't deploy.
UPDATE: Ok so the first set of errors is more related to Windows 10 I think. When the error appears again I try to manually copy the file and when I do I receive similar error in explorer.
error 0x800704c8: the requested operation cannot be performed on a file with a user-mapped section open.
can you try those things:
Close all other VS windows except one.
Clean the project you works on.
Try build project. If you get same errors, close all VS windows.
Delete 'bin' and 'obj' folders.
Open VS again and try building your project.
Then try deploying your project.
I know you might have found a fix already. But I had the same error after installing new emulators for my uwp application, after installing these emulators I seem to have gotten those errors. I thought uninstalling these emulators would be the fix, but was not. Now I run my program without restoring any missing packages and it seems to be the fix.
For anyone still facing the CopyWin32Resources Error on Windows, try uninstalling CbDefense (both Carbon Black Sensor and CB Defense Sensor 64bit). To much disbelief, this solution suggested by Microsoft resolved the issue for me!
I got this problem whenever I have my project in a folder that is synced by something like Dropbox. Pausing Dropbox always fixes the problem for me.
Fixed the problem. Moved the project out of the Visual Studio Project folder in My documents folder and into a projects folder on the C Drive. None of the errors have returned so I am guessing this is a windows 10 issue.

visual studio 2010 could not load file or assembly

I know there is plenty of question on that subject, but I didn't find any useful answer about my problem.
I got a project from a co-worker using mercurial. Now when i open the project I cannot open any C# file and I get the following message:
Could not load file or assembly, 'Microsoft.MSXML, Version =8.0.0.0,Culture = Neutral, PublicKeyToken=b03ff5f7f11d50a3a' or one of its dependencies. The file specified is unfindable.
Any idea? I don't know exactly what is in the code, in fact I've never see or programmed the code until now, but I know the code is working and my co-worker manage to make a installer and the software is working fine.
Try to install Microsoft Core XML Services to solve this problem
There was a problem inside Visual Studio 2010.
My resolution was:
I tried to create a basic C# applicaiton but the same error message pop-up
I tried to re-open a old project that I used to work on but the same error message pop-up.
So I used the following utility. I made a fresh install and how everything is working. I don't think it is the most efficient solution , but it worked.
Simply delete all folders in this path then rebuild your project.
C:\Users\'username'\AppData\Local\Temp\Temporary ASP.NET Files\root

Debugging issue in VS2010

Okay , weird things are happening to me again. This morning when i started my ASP.NET application, worked on it a bit and now when i try to publish it. I'm getting served with an error where i can't seem to find any documentation on
Error 1 Unable to apply a change while debugging. Source file '\Properties\AssemblyInfo.cs' was reloaded. You must restart the debugging session.
Anyone knows what to do with this ?
Confirm that neither this instance of visual studio nor another is debugging the binaries in question.
Restart Visual Studio. This will usually fix the problem.
If that still doesn't work, try disabling all addons and restarting visual studio one more time.
Finally, as a last resort, reinstalling visual studio has a way of fixing seemingly unfixable problems.
You can try closing the ASP.NET Development Server. It will be in the system tray (next to time), just double click it and click "Close" then just run again.
Or you can open Task Manager and end the process of Image Name: WebDev.Webserver...

VS 2008 suddenly can't start debugging session

I am having great problems running the application in the debugger from Visual Studio 2008.
When I'm using vshost.exe, it says:
And when vshost.exe is turned of, it simply states:
Interesting thing about it is that when i do use vshost, debugger is actually started and breakpoint is hit on the first line of the Main().
I tried:
rebuilding the project(s)
removing .ncb, .suo, .user for the projects
repairing Visual Studio 2008
changing the build architecture for the project
... no help there...
Any experience in (trouble)shooting that?
More info: some projects DO work, and one that I have to work on, does not.
I have some ideas such as:
trying to create NEW project, add thing by thing to it and see at what point it will start to miss behave
work it other way around, delete project by item by item to see when it will (if it will) be working OK again.
EDIT (for google, as I see that there are many similar questions on the web):
Errors:
Error while trying to run project: Unable to start debugging.
and
Error while trying to run project: Unable to start program '....\PlayKontrol.exe'
Try upgrading your Visual Studio to Service pack 1, if you haven't already.
Did you restarted your computer? You never know how windows will react to that :).
Also be sure there aren't any keys stuck, like the ctrl or windows key.
Note that the key does not have to be visually stuck, it can be stuck for visual studio and not for the explorer.
The most common source of sudden problems like this is corruption of one of the data files that vs uses to cache information between builds.
You've tried a clean build, but this won't delete everything. A real clean build is: quit vs, delete bin, obj, debug, release folders, delete all generated files in the root - primarily ncb. Do the same for any locally built libraries that you're project references.
The easiest way to do this is if you have the code in source control, as you can rename away your entire code folder and then force a get of all the source.
You often need to do all of these things in one hit to clear the problem.
Less frequently, a reinstall of vs will sort things out (although this sounds unlikely in your case if it is only one project that breaks)
Also think carefully about anything you might have installed just prior to it failing... And remember that some install effects may not occur until the next reboot so it could be days ago. A particular cause of this are automatic windows updates and trial versions of things like the vs 11 beta.
You might try running the application from outside of VS, but have a line of code that looks like this: Debugger.Launch(); where you want your first breakpoint.

Error Creating Debug Information - Code Won't Compile

I'm using VS 2008. When ever I make a change in my code and try to compile I get the following error:
Error 7 Unexpected error creating
debug information file 'C:\Documents
and Settings\jbezanson\My
Documents\MyProjects\DispatchBoard\DispatchBoard\obj\Debug\DispatchBoard.PDB'
-- 'C:\Documents and Settings\jbezanson\My
Documents\MyProjects\DispatchBoard\DispatchBoard\obj\Debug\DispatchBoard.pdb:
The process cannot access the file
because it is being used by another
process. ' DispatchBoard
Using Process Explorer, it is always devenv.exe that is locking the file. If I run in Release mode this does not happen. It started 2 days ago when I started a WPF application, and since then it happens with every application I work on.
The only info I could find from Google was referring to a bug in VS 2003.
Anyone else have this problem? How do I fix it? It is getting very annoying having to kill the file handle every time I want to compile.
If you have multiple instances of VS open, close other instances (apart from the one you are trying to compile) - this may resolve the issue.
When I have problems with locked files, I use Unlocker. (If you tried everything and it's not working, try this ;)
In case of broken link, here's a mirror.
Have you tried closing VS, deleting obj folder then restarting VS?
I had the same problem this morning and noticed that I had another project open that had a reference to the one that would not compile or debug. I removed the reference (as I didn't actually need it) and it was fine.
I changed the 'StartUp Project' of my solution to a project without reference to the locked file's project.
This solved the issue for me using VS 2010 SP1.
(Process Explorer said msvsmon.exe (started by devenv.exe) locked the pdb file.
After changing the startup project the processes msvsmon.exe and .vshost.exe disappeared and so did the file handle.)
Alex Clark, thank you for pointing me in the right direction.
The only thing that worked for me is to remove the optimizeCompilations="true" attribute from on the compilation element in my Web.Config file.
Compilation time may be a little longer, but it worked well.
To avoid that problem just open the project properties, go to Debug tab an untick "Enable the Visual Studio hosting process"
I had this issue today. In my case, I had just grabbed the data from my company's source control and instantly hit this issue when I tried to compile the project. The issue ended up being that the \bin folder was set to Read Only. To solve the issue, I just made the folder not Read Only.
I just came across the same problem today. And then I realized what went wrong: I had couple of Visual Studio windows opened at the same time, and one of them was in debug mode.
When I stopped debug mode in that one, the problem was solved.
That happens when you have a "fistfull of VS windows" opened.
Right Click The Folder that contains debug .pdb and uncheck the folders read-only propertys then ok. thats it.
This works for me with web projects in Visual Studio Express 2012 for Web:
Press F5 to begin debugging
"Do you want to execute last successful build?" - hit YES
At this point you could try a request - not sure if this step is necessary
Hit the stop button
Recompile successfully
I have solved a similar problem by adding these lines as a pre-build event:
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" move "$(TargetPath)" "$(TargetPath).locked"
With proper modifications, it might help your problem.
Since you say you have it on all applications you work on it sounds like a more global problem. You could try and reinit the vs2008 by writing
devenv.exe /setup
Edit: link to command line options
This worked for me. What I done was that close my visual studio and delete the .suo file and then re-open the solution. The locking should be disappeared now. Cheers.
Old topic, but something that worked for me. I had 2 projects in my solution, a class library type project and a windows form project. The windows form project was referencing the compiled binary and not the project itself in my case which was causing the lock. After changing the reference to the class library project, it worked properly.
Not need to restart or delete the file.Deleting will not be possible , you will get error message. Just rename the file and that is enough.
VS2010 will create another file for you as it wont find the origional. :)
I had the same issue from time to time. Usually no problem but once in a while... This particular time, it was impossible to work. I would shut the application down, and even that didn't work most of the time. I saw this post and a person said they had no issues until they started a WPF application. I was playing music (radio station) in the background with Windows 8 "Music" app. I had the idea that it was a Microsoft App built with Visual Studio. Once I stopped playing music, I never encountered the error. If you are reading this, see if you have any Microsoft apps running.
I also had the same issue. Tried all the suggestions above with no luck. I eventually change the Build Configuration from Debug to Release, the solution built...
This problem started occurring for me after changing from Cassini to IIS Express as my platform for debugging.
Cassini was much better than IIS Express but doesn't properly support the Integrated pipeline. IIS Express is hopeless.
This seems to be some sort of race condition in Visual Studio or IIS Express. It is nothing to do with one project locking another project - the locks are coming solely from the activity of the web application's build process.
Anyways, none of the above solutions worked for me. Unlocker doesn't seem to be supported for Windows 8 anymore. So instead I tried LockHunter. What I do is keep the LockHunter app open all day. If I get a complaint about some file being locked I copy and paste the file path into LockHunter then try again. This usually sorts out the problem but sometimes takes a few attempts.

Categories

Resources