Accessing a singleton class from a windows service

M

mma

hello everyone,

i have a solution that contains the following project types:
1. Class library
contains a singleton class that handles the data access (sql
server 2005).
2. Windows service.
uses the Class library's singleton class to manipulate data in
the data base server.
3. Windows application.
used for debuging the Class library's singleton class.

* I'm developing in VS2005 using c#.

The problem is:

When i try to get the singleton class's static instance from the
context of the windows service
i get an exeption.

the message is:

Service cannot be started.
System.Configuration.ConfigurationErrorsException:
The requested database myGovAlerts is not defined in configuration.

at

Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.ValidateConnectionStringSettings
(String name, ConnectionStringSettings connectionStringSettings)

at

Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.GetConnectionStringSettings
(String name)

at

Microsoft.Practices.EnterpriseLibrary.Data.DatabaseCustomFactory.CreateObject
(IBuilderContext context, String name, IConfigurationSource
configurationSource, ConfigurationReflectionCache reflectionCache)

at

Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.BuildUp
(IBuilderContext context, Type t, Object existing, String id)

at
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp
(IBuilderContext context, Type typeToBuild, Object existing, String
idToBuild)

at
Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp
(IBuilderContext c...


--------------------------------------------------------------------------------------------------------
p.s When getting the singleton instance from the context of the windows
application it works
great.
--------------------------------------------------------------------------------------------------------

As i understand according to the line in the message:

"at
Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp
(IBuilderContext c..."

the singletone's instance builder expects an IBuilderContext object.
the context that is given is the windows service's and that is probably
the problem.

how can i solve it?

thanks.
 
M

mma

No, i have installed the service using the command line utility:
installutil.exe.
the sevice is running with no problems if it doesnt call the singleton
class.

how do i deploy the 'service.exe.config' file?

thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top