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

  • Home
  • SEARCH
  • 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 3850490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:01:03+00:00 2026-05-19T17:01:03+00:00

I have an ASP.net project which involves using a custom IHttpModule. This module will

  • 0

I have an ASP.net project which involves using a custom IHttpModule. This module will sit in the pipeline and when certain criteria match up, it should invoke a method on a WCF service hosted in a simple C# console application on the same machine.

The code for the module is below:

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.SessionState;
using System.Web;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Configuration;
using System.ServiceModel;
using SimpleFarmStateServer;

namespace SimpleFarm
{
    public class SimpleFarmModuleSS : IHttpModule, IRequiresSessionState
    {
        protected string cache_directory = "";

        // WCF
        ChannelFactory<IStateServer> factory;
        IStateServer channel;

        public void Dispose() { }

        public void Init(System.Web.HttpApplication context)
        {            
            context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);

            setupFactory();
        }

        void setupFactory()
        {
            factory = new ChannelFactory<IStateServer>(
                    new NetNamedPipeBinding(),
                    "net.pipe://localhost/StateServer");
        }

        void context_PreRequestHandlerExecute(object sender, EventArgs e)
        {
            try
            {
                if (factory.State != CommunicationState.Opened)
                    setupFactory();

                channel = factory.CreateChannel();
                channel.LogAccess("Hello World!");
            }
            catch (Exception ex)
            {

            }
            finally
            {
                factory.Close();
            }
        }        
    }
}

My problem is that this runs the first time, but then subsequent attempts cause this error message

The communication object,
System.ServiceModel.Channels.ServiceChannel,
cannot be used for communication
because it is in the Faulted state.

It seems as if I am doing something wrong, and I am new to WCF in general so this is very likely.

I think the issue is surrounding the ChannelFactory being recreated, and this causes the faulted state.

  • 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-19T17:01:04+00:00Added an answer on May 19, 2026 at 5:01 pm

    The specific error probably means the factory faulted, threw an exception (which you’re swallowing) and then when the finally block executes, the factory.Close() call fails because the factory is faulted (if a WCF object is faulted, you need to call Abort() on it, not Close()).

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

Sidebar

Related Questions

I have created a a subclass of Table in my ASP.NET project which creates.
I have a ASP.NET project, in which I have a method with 10 local
In visual studio, I have an asp.net 3.5 project that is using MS Enterprise
I have an ASP.net project I'm looking at and they want to use MySQL.
I have an ASP.NET MVC project with a form. In the Action method that
I have an ASP.NET MVC project and I have a single action that accepts
I have a new ASP.NET MVC project (my first), and I had been running
I have an existing asp.net webforms project that uses Microsoft's Enterprise DAAB for the
I have a UserControl in my Asp.net project that has a public property. I
I have nant set up to build my ASP.NET MVC project and it works

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.