Error: Object reference not set to an instance of an object for Window Service in ASP.Net

redhook99
 
on Jan 26, 2017 01:53 AM
3056 Views

Thank you for your example on emailing in a window service.  I am getting this error below in my servicelog.txt file.

Simple Service started at 25/01/2017 01:47:23 PM
Simple Service Error on: 25/01/2017 01:47:23 PM Object reference not set to an instance of an object. at WindowsService3.Service1.ScheduleService()

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jan 26, 2017 01:58 AM
on Jan 26, 2017 03:11 AM

Hi redhook99,

You need to debug the code. Somewhere you are getting null value thats why the error. Please check the app setting key with the code  you are accessing from config file as mentioned in the article.

 

redhook99
 
on Jan 27, 2017 06:26 AM

This is my code exactly from example.

 

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings>
<!--<add key="Mode" value="Daily" />-->
<add key ="Mode" value ="Interval"/>
<add key="IntervalMinutes" value="1" />
<add key="ScheduledTime" value="15:00" />

</appSettings>

</configuration>

redhook99
 
on Jan 27, 2017 06:37 AM

I'm trying to debug the code but cannot step into code from VS2015.

 

redhook99
 
on Jan 27, 2017 06:57 AM

Ok I get it now.  The Appconfig is a seperate file and needs to exist in the same folder as the exe.  I thought it was part of the build. It is working now.  Thank you.