Question

I'm manually creating a WCF service that will act as a DAL and have created multiple projects to isolate core functionalities, and want to access the data through MiscServices.svc, which will be hosted (this architecture will also support multiple hosts). The solution hierarchy is as follows (each a separate project):

  • Models (entity sets)
  • Service contracts (interfaces): IMiscContracts.cs
  • Service libraries (classes): MiscServices.cs : IMiscContracts
  • Host (.svc files): MiscServices.svc

MiscServices.svc:

<%@ ServiceHost Language="C#" Debug="true" Service="MyProject.DAL.DB1.Service.MiscServices" CodeBehind="MyProject.DAL.DB1.Service.MiscServices.cs" %>

.Contracts and .Services is referenced in the Hosts project which contains the .svc's.

The project only has MiscServices.svc and a web.config:

 <system.serviceModel>
    <services>
      <service name="MyProject.DAL.DB1.MiscServices">
        <endpoint name ="MiscServicesEndpoint"
                  address="MiscServices.svc"
                  binding="wsHttpBinding"
                  contract="MyProject.DAL.DB1.Contracts.IMiscContracts" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>        
      </service>
    </services>

MiscServices.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Web;
using MyProject.DAL.DB1.Contracts;
using MyProject.DAL.DB1.Models;


namespace MyProject.DAL.DB1.Services
{
    /// <summary>
    /// Interface implementations
    /// </summary>
    public class MiscServices : IMiscContracts
    {

        private DB1DBContext dbContext = new DB1DBContext();

        /// <summary>
        /// Returns a simple input string
        public string GetString(string someString)
        {
            return String.Format("This is your string {0}", someString);
        }
.
.
.

The issue is that when I try to publish the Hosts project, I get the following errors:

'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected. 
Declaration expected.

... for the one line in the .svc file, and I'm not sure about how to correct this.

Was it helpful?

Solution

It seems that the issue was in the project types that VS maintains under the hood.

I removed the project, created a brand new WCF service project, remove the interface, and classes, leaving only the .svc file, and it worked just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top