none
Object reference not set to an instance of an object WCF sql and OLEDB Excel Transactions RRS feed

  • Question

  • I have my WCF service that just uses Jet OLEDB4.0 to read excel and do some data transactions back to SQLServer.

    I have directly used a string to pass on Connection string in the code and then do the transactions so its obvioous that there wouldnt be any entries of connection strings in the web.config file. I run it locally and it works fine. When I pass parameters and my webservice returns the result I want.

    But when I host my webservice I am stumped with this not so useful error.

    My web.config would look somethign like this

    <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation targetFramework="4.5" />
        <authentication mode="Windows"/>
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>   
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>

    </configuration>

    This is the error that comes up and I dont know what I should do with just this error log. I can not debug the service on the IIS as I dont have VS installed there. And neither do I have end points defined in my config such that i can try to debug it locally. Please help resolve this issue.

    Object reference not set to an instance of an object.

    Server stack trace:
       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Service.Import(String path, Int32 Bg, String Name)
       at ServiceClient.Import(String path, Int32 Bg, String Name)



    • Edited by newbiems Friday, August 30, 2013 3:37 PM
    Thursday, August 29, 2013 8:49 PM

Answers

  • Hi newbiems,

    Based on the configuration fragment you provided, it seems you're using the default configuration for WCF service. Since you cannot perform live debugging on the service hosting machine. Then, is it possible that you configure the service to enable tracing (in the web.config file) so that you can try inspecting the tracing log file to see if we can find any useful error info there.

    #Service Trace Viewer Tool (SvcTraceViewer.exe)
    http://msdn.microsoft.com/en-us/library/ms732023.aspx

    #how to understand the trace viewer of WCF
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/e26eb11b-3224-45ef-af25-9f456c5e3830/how-to-understand-the-trace-viewer-of-wcf

    It would also be helpful if you can get a local development machine (with the same server enviornment) to repro this behavior so that you can perform live debugging against the service.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 2, 2013 9:10 AM
    Moderator

All replies

  • <copied>

    Object reference not set to an instance of an object.

    <end>

    In layman terms, it means that an object being referenced doesn't exist, it is not in memory and  it is a null value.  Here is a simple  example of what the error means.

    private Newbiems  theobj = new Newbiems();

    theobj is a instance of the Newbinems class. The object exist in memory, and you can reference the object.

    theobj.name = "Larry"

    var name = theobj.name

    The above code has no problem with the object because the object is a instance and it exist in memory.

    private Newbiems  theobj    --> theobj has been declared but the object has not been created "new" it is not an instance in memory it is a null value -- nothing.

    theobj.name = "Larry"  ----> and BOOM the program is going to blow up, because theobj was referenced but there is not an instance of the object in memory.

    If theobj did exist in memory and you did this, then what is going to happen if it's referenced again?

    theobj = null;

    theobj.name = "Larry"  ----> well of course the program is going to blowup, because there is not an instance of theobj in memory anymore. It was set to a null value.

    When the object doesn't exist in memory when code is executing and trying to reference it's going to blow up. You are going to have to debug the code.

    It doesn't matter if it's the Java or the .NET world the principles are the same. 

    http://alfredjava.wordpress.com/2008/07/08/class-vs-object-vs-instance/

               
    Thursday, August 29, 2013 10:45 PM
  • Hi newbiems,

    Based on the configuration fragment you provided, it seems you're using the default configuration for WCF service. Since you cannot perform live debugging on the service hosting machine. Then, is it possible that you configure the service to enable tracing (in the web.config file) so that you can try inspecting the tracing log file to see if we can find any useful error info there.

    #Service Trace Viewer Tool (SvcTraceViewer.exe)
    http://msdn.microsoft.com/en-us/library/ms732023.aspx

    #how to understand the trace viewer of WCF
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/e26eb11b-3224-45ef-af25-9f456c5e3830/how-to-understand-the-trace-viewer-of-wcf

    It would also be helpful if you can get a local development machine (with the same server enviornment) to repro this behavior so that you can perform live debugging against the service.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 2, 2013 9:10 AM
    Moderator