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 4548738
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:15:46+00:00 2026-05-21T16:15:46+00:00

I am trying to write some unit tests that test the endpoints for my

  • 0

I am trying to write some unit tests that test the endpoints for my WCF service and to do this I want to host the service within the unit tests itself rather than in IIS. I have found this article that I have read through and made the changes so I am hosting it using ServiceHost and I can see that the unit tests are trying to run it but I seem to be hitting a bit of a problem.

When I run the tests, I get the following error at the point of opening the service:

This service requires ASP.NET
compatibility and must be hosted in
IIS. Either host the service in IIS
with ASP.NET compatibility turned on
in web.config or set the
AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode
property to a value other than
Required.

This is being caused by the following attribute setting on my services class:

[AspNetCompatibilityRequirements( RequirementsMode = AspNetCompatibilityRequirementsMode.Required )]

I have then tried to add the following into my app.config but it doesn’t seem to make any difference:

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>

Any ideas how I can get past this issue?

  • 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-21T16:15:46+00:00Added an answer on May 21, 2026 at 4:15 pm

    As stated by the error message, the ASP.NET compatibility mode requires the WCF service to be hosted in an ASP.NET web server.

    If you wish to run some integration tests against your WCF service on your local machine you can always host the service in the Visual Studio Development Server (a.k.a. Cassini). I highly recommend you to take a look at CassiniDev, an open source library that allows to run a lightweight ASP.NET web server in process, which is especially useful for unit testing scenarios.

    Here’s an example of how you would use CassiniDev in a unit test using MSTest:

    [TestClass]
    public class MyServiceTest
    {
        private CassiniDevServer host;
    
        [TestInitialize]
        public void SetUp()
        {
            var host = new CassiniDevServer();
            host.StartServer(@"RelativePathToServiceProjectDir", 8080, "/", "localhost");
        }
    
        [TestCleanup]
        public void TearDown()
        {
           host.StopServer();
        }
    }
    

    Related resources:

    • CassiniDev Documentation
    • Using CassiniDev with unit testing frameworks and continuous integration
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write some unit tests for a gwt-dispatch service with JUnit. I'm
I have some Web API methods that I want to write unit tests for.
I'm currently trying to write some unit test on some javascript files. My first
I'm having some difficulty writing some Unit Tests to test a custom ModelBinder that
I am trying to write a unit test using .NET 4 to ensure that
I'm trying to write a unit test with phpunit for a model that uses
I am trying to write some unit tests for my code. In out project
I'm trying to write some LINQ To SQL code that would generate SQL like
I'm trying to write some C# code that calls a method from an unmanaged
I was trying to write some code that would check if an item has

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.