InvalidOperationException With WCF Service In SharePoint 2010

At a client today we were focusing on moving a bunch of custom, in-house deliverables to a SP 2010 RC environment so that we could test all the moving pieces required for their environment to function. About half way through all successful, uneventful testing, we finally hit an error when examining a WCF service hosted in SharePoint. The particular error message was:

[InvalidOperationException: Operation is not valid due to the current state of the object.] Microsoft.SharePoint.ApplicationRuntime.SPLayoutsMappedFile.MapLayoutsVirtualPath(String virtualPath)

If you run into this error, its pretty easy to fix. In the ServiceBehaviorAttribute of your service class, ensure the following is present:
As well in the SharePoint web.config, in the serviceHostingEnvironment make sure the aspNetCompatibilityEnabled attribute is set to true.


Layouts Pages Custom Errors – Change Web.Config In Layouts!

If you are working with a SharePoint 2010 application page, and sitting there wondering why when you change the callstack and customErrors element in the root web.config for the web application to Off and it’s not taking effect, you have to change it in the web.config in the layouts directory too.

I was scratching my head for a bit on this this morning!


TFS Proxy Server Unexpected Shutdowns

TFS Proxy Servers are essential for my current client’s TFSenvironment because they allow the disparate SharePoint development environment to experience improved network performance by caching copies of VC files. Since this particular environment is geo-distributed, this is a necessary architectural requirement in order to maintain appropriate developer efficiency.

Recently, a strange issue was occurring with my clients geo-environment where the proxy servers would start shutting down repetitively. The exact error you may run into is:

The VSTF Proxy Server stopped at [server]. The application is being shutdown for the following reason: HostingEnvironment. For more information …..”

Now this can happen for a variety of reasons, but first thing is you should enable proxy server tracing to get some more relevant error information by opening the web.config in the VersionControlProxy folder by setting the traceDirectoryName to a familiar storage location and changing traceWriter to true. For this particular error, one of the error returns can be:

Detailed Message: TF53002: Unable to obtain registration data for application VersionControl.
TF30055: Visual Studio could not find or read the Team Foundation Server server name in the configuration file. Contact your Team Foundation Server administrator. (type VstfNotConfiguredException)

If you get this error, the TfsNameUrl appsetting is not configured in the web.config file for the proxy server. Locate the:


element and change it. After, check your IIS app pool setting and check that the recycle interval or memory limit. After, you should be good to go!