Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7157937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T12:58:35+00:00 2026-05-28T12:58:35+00:00

I have something like this: MathServiceLibrary (WCF Service Library) [ServiceContract] public interface IMathService {

  • 0

I have something like this:

MathServiceLibrary (WCF Service Library)

[ServiceContract]
public interface IMathService
{
        [OperationContract]
        int Add(int x, int y);
        [OperationContract]
        int Multiply(int x, int y);
}

public class MathService : IMathService
{
        public int Add(int x, int y)
        {
            return x + y;
        } 

        public int Multiply(int x, int y)
        {
            return x * y;
        }
}

<behaviors>
   <serviceBehaviors>
      <behavior name="defaultServiceBehavior">
         <serviceMetadata httpGetEnabled="true" />
      </behavior>
   </serviceBehaviors>
</behaviors>
<services>
   <service behaviorConfiguration="defaultServiceBehavior" 
            name="MathServiceLibrary.MathService">
       <endpoint 
           address="mex" 
           binding="mexHttpBinding" 
           contract="IMetadataExchange" />
       <endpoint 
           address="math" 
           binding="wsHttpBinding" 
           contract="MathServiceLibrary.IMathService" />
       <host>
          <baseAddresses>
             <add baseAddress="http://localhost:8080/" />
          </baseAddresses>
       </host>
    </service>
 </services>

If I run this I can see the WCF Test Client and everything is ok.

Now I want to host this service into IIS so I create a web site and add a reference to MathServiceLibrary.

I have this ms.svc

<%@ ServiceHost Language="C#" Debug="true" 
    Service="MathServiceLibrary.IMathService" %> 

and this web.config

    <system.serviceModel>
        <services>
            <service behaviorConfiguration="defaultServiceBehavior" name="MathServiceLibrary.MathService">
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
                <endpoint address="" binding="wsHttpBinding" contract="MathServiceLibrary.IMathService">
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="defaultServiceBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    </system.serviceModel>

When I right click on ms.svc view in browser I get this:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.ArgumentException: ServiceHost only supports class service types.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: ServiceHost only supports class service types.]
System.ServiceModel.Description.ServiceDescription.GetService(Type
serviceType) +12229075
System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2&
implementedContracts) +55
System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection
baseAddresses) +154
System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49
System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +151
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type
serviceType, Uri[] baseAddresses) +30
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String
constructorString, Uri[] baseAddresses) +420
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath) +615

[ServiceActivationException: The service ‘/MathWebSite/ms.svc’ cannot be activated due to an exception during compilation. The
exception message is: ServiceHost only supports class service types..]
System.Runtime.AsyncResult.End(IAsyncResult result) +679246
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
result) +190
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication
context, String routeServiceVirtualPath, Boolean flowContext, Boolean
ensureWFService) +234
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +355
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+148
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

I can’t figure out what I am missing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T12:58:36+00:00Added an answer on May 28, 2026 at 12:58 pm

    Change your ms.svc as below

    <%@ ServiceHost Language="C#" Debug="true" Service="MathServiceLibrary.MathService" %    > 
    

    You have to give the class name instead of interface name

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: class Base { public: static int Lolz() { return
I have something like this: public override int SaveChanges() { foreach (var changeLog in
I have something like this: [Description(Sets the color.), Category(Values), DefaultValue(Color.White), Browsable(true)] public Color MyColor
I have something like this in my Spring Application: public class Book{ public Book(){
I have something like this: create table account ( id int identity(1,1) primary key,
I have something like this in mind: <appSettings> <add key=ConfigName value=configuration culture=1033 /> <add
I have something like this: private var myVideo:Video; public var videoDisplay:UIComponent; ... videoDisplay.addChild(myVideo); ...
i have something like this <body> <h2> Blue <span> <a ....>add to combo</a> </span>
I have something like this: public void Delete(T entity) { Context.DeleteObject(entity); Context.SaveChanges(); } I
I have something like this: public class CPerson: INotifyPropertyChanged public class CPeople: SortedSet<CPerson> public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.