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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:41:34+00:00 2026-05-13T12:41:34+00:00

I have a WCF service with two methods, Ping and PutAddress. Ping works fine,

  • 0

I have a WCF service with two methods, Ping and PutAddress. Ping works fine, but PutAddress was failing to initialize NHibernate correctly. Narrowing down the issue, I realized that the relevant settings from Web.config were not being read by PutAddress.

Strangely, Ping does have access to the settings from Web.config. I removed all of the NHibernate code and boiled it down to just trying to read the settings. Ping is able to read the settings (returns non-null, values in result are correct) while PutAddress’ result is null.

Again, NHibernate is now completely out of the picture. Both methods simply try to read the relevant settings from Web.config. Ping succeeds while PutAddress fails.

Any thoughts?

Interface:

[ServiceContract]
public interface IMyService
{

    [OperationContract]
    string Ping();

    [OperationContract]
    Address PutAddress(Address address);
}

Implementation:

public class MyService : IMyService
{
    public string Ping()
    {
        NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration result = 
           (NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration)
         System.Configuration.ConfigurationManager.GetSection("hibernate-configuration");
        if (result == null)
        {
            System.Diagnostics.Debugger.Break(); // Does NOT break, "Pong" returned 
        }

        return "Pong";
    }

    public Address PutAddress(Address address)
    {
        NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration result =
           (NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration)  
            System.Configuration.ConfigurationManager.GetSection("hibernate-configuration");
        if (result == null)
        {
            System.Diagnostics.Debugger.Break(); // Breaks, result is null
        }

        return address; // Return version potentially modified with DB-assigned ID
    }
}

EDIT:

Here is the (sanitized) Web.config

<?xml version="1.0"?>
<configuration>
  <configSections>
    <!-- NHibernate Section -->
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate"/>
    <!-- Log4Net Section -->
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
  </configSections>
  <!-- NHibernate Configuration -->
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="dialect">
        NHibernate.Dialect.MySQLDialect
      </property>
      <property name="connection.provider">
        NHibernate.Connection.DriverConnectionProvider
      </property>
      <property name="connection.driver_class">
        NHibernate.Driver.MySqlDataDriver
      </property>
      <property name="connection.connection_string">
        Server=localhost;Database=DB;User ID=USER;Password=PASS
      </property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
      <property name="show_sql">true</property>
      <mapping assembly="MyService"/>
    </session-factory>
  </hibernate-configuration>
  <!-- Log4Net Configuration -->
  <log4net>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender, log4net">
      <layout type="log4net.Layout.PatternLayout, log4net">
        <param name="ConversionPattern" value="%d %p %m%n"/>
      </layout>
    </appender>
    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender,log4net">
      <param name="File" value="log.txt"/>
      <param name="AppendToFile" value="true"/>
      <param name="DatePattern" value="yyyy.MM.dd"/>
      <layout type="log4net.Layout.PatternLayout,log4net">
        <conversionPattern value="%d %p %m%n"/>
      </layout>
    </appender>
    <root>
      <priority value="DEBUG"/>
      <appender-ref ref="ConsoleAppender"/>
    </root>
    <logger name="NHibernate" additivity="false">
      <level value="WARN"/>
      <appender-ref ref="RollingFile"/>
      <appender-ref ref="ConsoleAppender"/>
    </logger>
    <logger name="NHibernate.SQL" additivity="false">
      <level value="ALL"/>
      <appender-ref ref="RollingFile"/>
      <appender-ref ref="ConsoleAppender"/>
    </logger>
  </log4net>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
  • 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-13T12:41:34+00:00Added an answer on May 13, 2026 at 12:41 pm

    Found the problem – one call was from a Unit Test that I hand-coded, which uses MyServiceClient that was generated by Visual Studio when I added a Service Reference. The other call was from a unit test that was created by the Visual Studio (2010) Unit Test wizard, which just instantiated MyService as an object. The VS-generated unit test was running in-process as a result.

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

Sidebar

Related Questions

I have a WCF service which has two methods exposed: Note: The wcf service
I have a WCF service with three methods. Two of the methods return custom
I have self hosted net tcp WCF service that exposes two methods and the
I have two Methods in a WCF Service say Method1() { _currentValue = 10;
I'm hosting my first WCF service in IIS. I have two methods, 1 to
I have a WCF client/service app that relies on secure communication between two machines
I have two Services called TemplateService, TemplateReportService (both defined in one WCF Service Library)
I have two WCF clients consuming a 3rd party web service. These two clients
I have a WCF environment hosted on a windows service. I have two hosts
I have a WCF web service that exposes several business methods. I also have

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.