Posts Tagged ‘WCF’

Okay, I’ve not blogged for a while and this was mainly due to being subjected to SharePoint 2007 development once again.  However, I’m now into the land of SharePoint 2013 and I’ve no doubt I will be actively posting once more as I discover various nuances of the new environment.

So, here’s my first, which was a bit of a head scratcher!! After creating a custom list, I tried to add a new list item and received the following unhelpful error.

clip_image002

After a bit of Google-ing as few fixes were suggested, but none of which seemed like a viable solution. For reference, so you don’t go down same route, these were :

  • Enable Anonymous access
  • Restart the SharePoint Search Host Controller  service
  • Lack of RAM

None of these work, so don’t even try.

Next step, was to go to the logs where I found a call was being made to the /_vti_bin/client.svc/ProcessQuery

However, on opening the WCF service in the browser I received the following 500 error  “Operation is not valid due to the current state of the object” which lead me the eventual problem.

My web.config didn’t have a serviceHostingEnvironment element.  Adding the following to the <system.serviceModel> section resolved the issue

Service Hosting Element
  1. <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

However, you may have the following already in your config

Wrong Service Hosting Environ
  1.  
  2. <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>

If you remove  multipleSiteBindingsEnabled="true"  it should work

Hope this helps you save a few hours

Open-mouthed smile

Advertisements

Listed below are some issues and solution you may come across when trying access a LINQ to Entity layer from a WCF Service located in a separate project.

Problem:
Argument Exception: “The specified named connection is either not found in the configuration, not intended to be used with the EntityClient Provider, not valid.”

Argument Exception: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid

Solution:

The class library which contains the EDMX file contains an app.config file with the entity connection string. When access this from the WCF layer, there is no reference to it unless you include it in the web.config of the WCF layer

To fix the problem, copy the connection string from the app.config to the ConnectionStrings section of the web.config of the WCF project.

However, on doing this, you may receive another exception message:

MetadataException: Unable to load the specified metadata resource.
MetadataException : Unable to load the specified metadata resource

connectionString=”metadata=res://*/Model.Project.csdl|res://*/Model.Project.ssdl|res://*/Model.Project.msl;

to

connectionString=”metadata=res://*/;