1

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.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
BBristow
  • 11
  • 1
  • 4
  • Try changing the server config :`` then any server side exceptions should be sent to the client – James S Oct 16 '13 at 15:55
  • I had it marked as true initially. I changed it to false due to this error: The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'. – BBristow Oct 16 '13 at 16:15
  • I'll attempt to fix that issue for more details on the exception. Thanks! – BBristow Oct 16 '13 at 16:16
  • I added the true flag. No new details were given. Still in the same boat. – BBristow Oct 16 '13 at 17:45
  • Almost all cases of `NullReferenceException` are the same. Please see "[What is a NullReferenceException in .NET?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)" for some hints. This might be a simple service programming error, having nothing to do with the configuration. – John Saunders Oct 16 '13 at 23:06
  • It ended up being a combination of three things. After working with a complex program and failing I went back to the basics. As this is a new server I wanted to make sure that nothing on the server itself was causing the problem. After a few hours of testing I found the problems. Nothing to do with the configuration (although I spent most of my time looking there!) – BBristow Oct 18 '13 at 13:41
  • Sharing the answers is a pivotal part of the SO purpose. Could you elaborate on your 3 things some more? – Hardrada Jan 13 '14 at 21:39

1 Answers1

2

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>

Sanjay Rabadiya
  • 478
  • 5
  • 10
  • You can also use the Service Configuration Editor and Service Trace Viewer which is part of Windows SDK Tools. It makes configuring and viewing service traces easy (the tools are installed as part of Visual Studio iirc) – Charleh Oct 16 '13 at 20:10
  • System.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details. ---&gt; System.Xml.XmlException: The body of the message cannot be read because it is empty. --- End of inner exception stack trace --- – BBristow Oct 16 '13 at 20:27
  • I'm guessing this is a serialization issue? I've verified that the object being sent from the client to the server is not null. – BBristow Oct 16 '13 at 20:28
  • I dont think so it's serialization issue because SVC log should be give you proper msg for serialization issue.is their any enum without '0' value in your service method param? – Sanjay Rabadiya Oct 16 '13 at 20:39