I am in the middle of trying to write my first windows service using C# and .NET framework and am having trouble referencing a project within the same solution within the service. My MVC solution structure within VS2012:
- 1 MVC project (web app project)
- 1 additional processing project (used for extended processing within controllers)
- 1 service project
- 1 install shield le project (successfully installs the service project)
Within my service (which I want to fire every x mins) I am referencing methods in the extended processing project that intellisense is able to detect when I am writing code within the service project (I have a using extendedProcessingProject; using webAppProject; and a project references to the extendedProcessingProject and web app project).
The service installs to my local pc without errors. When I start the service I have an error being logged that I cannot seem to figure out:
Exception body: ReminderEmailService Object reference not set to an instance of an object. System.Collections.ListDictionaryInternal
System.NullReferenceException: Object reference not set to an instance of an object.
at ReminderEmailService.ReminderEmailService.ReminderEmails(Object source, ElapsedEventArgs e)
at ReminderEmailService.ReminderEmailService.SendReminderEmails(Object source, ElapsedEventArgs e)
Void SendReminderEmails(System.Object, System.Timers.ElapsedEventArgs)
I know can see though using the System.Diagnostics.Debugger.Launch();
List<SessionReminder> sessions = Queries.GetSessionsToRemind();
//sessions does not have a value, method returns a list of 1
//I suspect this is a project reference issue
debugString += "sessions: \n" + sessions.ToString();
//exception thrown on this line--I suspect because sessions is null
I am using the .NET4.0 (not client profile) on all projects within my solution. Any insight on how to enable my windows service to correctly access these assemblies (webappproject.dll and extendedProcessing.dll) would be much appreciated, as these dll's are being installed by install shield.