BBristow
BBristow

Reputation: 11

WCF Error - Object reference not set to an instance of an object. Production service not working

I'm new to writing questions, long time reader. If I omit something please let me know.

I have looked through many different scenario's and possible fixes and have been unable to get my WCF Service working correctly.

My service is responsible for passing data from many different sets to a master repository. The client gathers the data at the local set level and passes it to the service which inserts the data and passes back a result message. Again in the test environment this worked normally.

In production I added the service to an off-site server and configured the client on a remote set. The client was able to configure and receive updates from the service. Up until now everything worked correctly. However once the client attempted to transfer data across it received the following error "Object reference not set to an instance of an object."

Through bug checking I have confirmed there are no connection string issues to the db. I ran the same data transfer again in my test environment with no issues. I was able to connect to the .svc url on the local set.

I've added logging at different points through the data contract method call and none of these logs have triggered any results. I've also tested the write functionality on a test app which confirmed there were no issues with credentials writing to the temp folder. Eg:

public Result InsertVenueRecord(Venue v)
{
        System.IO.File.WriteAllText(@"C:\temp\MadeItToVenue" + DateTime.Now.Ticks.ToString() + ".log.txt", "insertVenue()\r\n\r\n");
        int oldId = v.VenueId;
        try
        {
            System.IO.File.WriteAllText(@"C:\temp\MadeItToVenue" + DateTime.Now.Ticks.ToString() + ".log.txt", "insertVenue()\r\n\r\n");
            //Check Address 
            if (v.Address.AddressId != 0)

The client app.Config looks as follows:

    <configuration>
    <system.serviceModel>
      <bindings>
        <basicHttpBinding>
          <binding name="BasicHttpBinding_placeholder" />
        </basicHttpBinding>
      </bindings>  
      <client>
        <endpoint address="Removed" binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_placeholder" contract="placeholder.placeholder"
          name="BasicHttpBinding_placeholder" />
      </client>
    </system.serviceModel>
  <appSettings>
    <add key="DTFirstWave" value="Venue|Event|EventSurveyLocation|Agent|LoginHistory|LoginUsed"/>
  </appSettings>
  <connectionStrings>
    <!-- Removed Connection Strings -->

  </connectionStrings>
</configuration> 

The service webconfig looks as follows:

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <httpRuntime/>
    </system.web>
    <system.serviceModel>
        <bindings>
             <basicHttpBinding>
                  <binding allowCookies="true" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="32" maxStringContentLength="52428800" maxArrayLength="52428800" maxBytesPerRead="52428800" maxNameTableCharCount="52428800"/>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>

 <directoryBrowse enabled="true"/>
 </system.webServer>
 <connectionStrings>
 <!--Removed -->
 </connectionStrings>
</configuration>

I'm at a loss as to why this isn't working.

Upvotes: 1

Views: 8476

Answers (1)

Sanjay Rabadiya
Sanjay Rabadiya

Reputation: 488

plz enable your service SVC log by just add system.daignostics in your service config.It will give you proper error on production.

It will create "App_tracelog.svclog" file in your service dir.

<system.diagnostics>
<sources>
  <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
    <listeners>
      <add name="ServiceModelTraceListener" />
    </listeners>
  </source>
  <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
    <listeners>
      <add name="ServiceModelTraceListener" />
    </listeners>
  </source>
  <source name="System.Runtime.Serialization" switchValue="Verbose,ActivityTracing">
    <listeners>
      <add name="ServiceModelTraceListener" />
    </listeners>
  </source>
</sources>
<sharedListeners>
  <add initializeData="App_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp" />
</sharedListeners>

Upvotes: 2

Related Questions