Requirement: Create a WCF service inside SharePoint Layouts folder so that it can be used with in SharePoint objects such as WebParts comfortably.
Note: WCF Services development for SharePoint is not covered here.
Issue: After deploying the service to Layouts using Visual Studio IDE, it throws an error while browsing the service.
Error details:
"System.IO.FileNotFoundException: Could not load file or assembly '$SharePoint.Project.AssemblyFullName$' or one of its dependencies. The system cannot find the file specified. at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at..........
"
Solution:
By default in SharePoint 2010, the .SVC templates package is not configured, We need to configure this with a change the target file.
Steps are provided below:
1. Check for the target file (Microsoft.VisualStudio.SharePoint.targets) in the following localtion:
$(TokenReplacementFileExtensions);xml;aspx;ascx;webpart;dwp;svc
Note: WCF Services development for SharePoint is not covered here.
Issue: After deploying the service to Layouts using Visual Studio IDE, it throws an error while browsing the service.
Error details:
"System.IO.FileNotFoundException: Could not load file or assembly '$SharePoint.Project.AssemblyFullName$' or one of its dependencies. The system cannot find the file specified. at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at..........
"
Solution:
By default in SharePoint 2010, the .SVC templates package is not configured, We need to configure this with a change the target file.
Steps are provided below:
1. Check for the target file (Microsoft.VisualStudio.SharePoint.targets) in the following localtion:
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools
2. Open the file in a Notepad or Textpad and search for ;ascx and and in the same line add ;svc as given below:
3. Save the changes and close it.
Deploy the project that has WCF service (SVC) files from Visual Studio. This should resolve the issue.
Note: This change is required in each developer machines that deploy the solution using Visual Studio. This change is not required for Non Development Environments like Test or Production (where visual studio deployments are not possible) since the WSP that is generated from a Developer machine contains the required SVC file in correct format