Thursday, May 29, 2014

VS 2013: The requested operation cannot be performed on a file with a user-mapped section open


You try to build your project in Microsoft Visual Studio 2013 and you get the following error.

The requested operation cannot be performed on a file with a user-mapped section open...

You have even rebooted the computer and this problem returns.


There are some windows open with a resource (most likely a config file) related stuff open in Visual Studio 2013.

The reason why rebooting would not work is that Visual Studio keeps track of the session state next time you reopen the project that causes the problematic document open again.


Close all the documents and rebuild (yes, it's just as simple as that!).

Tuesday, May 27, 2014

Microsoft Web API: no type was found that matches the controller named..."


You have renamed a Web API 2 project, most likely borrowed some other sample code and now you want to modify it for your own purpose.

After you do this, and try to re-test the API to see if it still works, you get "no type was found that matches the controller named..."

You have renamed just about everything, including your default namespace in the entire project.

Root Cause:

It appears that there is some caching and old code is remaining in the project.

Fix that Worked for Me

In my situation, what ultimately worked was getting into the./bin directory of my Web API project and remove everything inside of it.

You also may want to move the Controller class files in the controller folder to another temporary location, then, have the Visual Studio create an empty skeleton controller class. Compile to make sure it builds. Then paste back the guts of the original logic. When you do this, you may go ahead and change the name of the class from the original to see that works.

You would think that Clean of the build would work, but I did try this and did not work for me until I manually deleted the bin contents.

If you are using the IIS Express server, then what you need to make sure is that it is completely killed off. In my case, I made sure of this by restarting the computer altogether.

At this time of writing, I am fairly new to this MVC stuff, so there are actual reasons why this broke in the first place. If you know really why, please be sure to share the knowledge with us.