A A A Font Size

MOSS Mania

Using a Config File for Windows SharePoint Services Timer Jobs

One of the biggest problems I've had with timer jobs is that you cannot access the membership provider or role providers with them because they do not have a configuration value.  Then if you want to read from a configuration file, you have to point it to one of the web.configs of the site.
 
Not any more.  I was looking around for a way to add an app.config to the timer service and stumbled upon Jason Huh's blog post about using the Microsoft Enterprise Library with Timer Jobs.  I figured I would be able to use the same configuration for my projects.
 
All you need to do is create a config file for OWSTimer.  You can do this one of two ways, you can deploy this using a solution or you can do it manually. 
 
To do it manually, navigate to the hive (Program Files\Common Files\Microsoft Shared\web server extensions\12) and then open up the BIN folder.  Now create a new file named OwsTimer.exe.config.  In this file, you can place your config settings, this works just like an app.config or a web.config file that you would add in visual studio.
 
I've placed an example config file, but the Membership Provider and Role Provider nodes are not filled all of the way out, you can replace this with your own information or just remove the membership and role manager nodes completely.
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="ConnString" connectionString="ConnectionStringGoesHere" />
  </connectionStrings>
  <system.web>
    <membership defaultProvider="MembershipProvider">
      <providers>
        <add name="MembershipProvider" />
      </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="RoleProvider">
      <providers>
        <add name="RoleProvider" />
      </providers>
    </roleManager>
  </system.web>
  <appSettings>
    <add key="SiteUrl" value="http://sharepointsite"/>
    <add key="ProviderPrefix" value="RoleProvider"/>
  </appSettings>
</configuration>
 
Using this, you will be able to finally use a configuration file with your timer services without having to hard code the site that you are going to read the config settings from.
 
For more information on deploying this with a solution, check out Jason Huh's blog post:

http://www.jyhuh.com/blog/archive/2007/09/18/Microsoft_Enterprise_Library_with_SharePoint_TimerJob.aspx
You must sign in to rate content.
(1 ratings)

Comments

Re: Using a Config File for Windows SharePoint Services Timer Jobs

You can use the web.config file of your sharepoint web app too - see http://knrs.blogspot.com/2008/01/sharepoint-read-webconfig-inside-timer.html
SUG Anonymous User at 1/22/2008 3:38 PM
You must sign in to rate content.
(Unrated)

Config file for SharePoint Feature

Hi Not sure if you will be able to help me but my main question is how do you attach a config file to a SharePoint Feature? I have created a timed job, every couple of minutes it connects to a web service to pull data into some lists within a site collection. When I move this timed job to another environment (say from development to test) it connects to a different web service so I want to have a config file so I can modify the connection to the web service without having to build the project again in visual studio which is my current deployment method. I do see in my build output folder it does create a config file but my deployment method is to take .dll file that is created and drop that into the GAC and then activate the feature using the stsadm tool so by the look of things the config file isn’t used. Any help would be great Thanks Mark
SUG Anonymous User at 1/29/2008 8:01 PM
You must sign in to rate content.
(Unrated)

Custome timer jobs to run an .exe file

I need to run an exe file using sharepoint custome timer jobs.
can you briefly explain  me how can i do this.i knew that i have to use spjobdefination class,spscheduler class and spminitescheduler classes.i don't know proper way to do this.
Thanks in advance.
SUG Anonymous User at 3/10/2009 3:17 AM
You must sign in to rate content.
(Unrated)

Re: Re: Using a Config File for Windows SharePoint Services Timer Jobs

The reason I wouldn't point this to the main config file is for objects that use the Provider Model that look up on the current web.config.  The best example would be the membership provider.
Mike Parrill at 3/18/2008 5:33 PM
You must sign in to rate content.
(Unrated)

Re: Using a Config File for Windows SharePoint Services Timer Jobs

I tried creating a owstimer.exe.config file under 12\bin but the job is not picking up that config file when i do ConfigurationManager.ConnectionStrings[0].ConnectionString
SUG Anonymous User at 6/5/2008 2:39 PM
You must sign in to rate content.
(Unrated)

Re: Using a Config File for Windows SharePoint Services Timer Jobs

I tried creating a owstimer.exe.config file under 12\bin but the job is not picking up that config file when i do ConfigurationManager.ConnectionStrings[0].ConnectionString
SUG Anonymous User at 6/5/2008 2:39 PM
You must sign in to rate content.
(Unrated)

Re: Re: Using a Config File for Windows SharePoint Services Timer Jobs

The reason I wouldn't point this to the main config file is for objects that use the Provider Model that look up on the current web.config.  The best example would be the membership provider.
Mike Parrill at 3/18/2008 5:33 PM
You must sign in to rate content.
(Unrated)

Custome timer jobs to run an .exe file

I need to run an exe file using sharepoint custome timer jobs.
can you briefly explain  me how can i do this.i knew that i have to use spjobdefination class,spscheduler class and spminitescheduler classes.i don't know proper way to do this.
Thanks in advance.
SUG Anonymous User at 3/10/2009 3:17 AM
You must sign in to rate content.
(Unrated)

Config file for SharePoint Feature

Hi Not sure if you will be able to help me but my main question is how do you attach a config file to a SharePoint Feature? I have created a timed job, every couple of minutes it connects to a web service to pull data into some lists within a site collection. When I move this timed job to another environment (say from development to test) it connects to a different web service so I want to have a config file so I can modify the connection to the web service without having to build the project again in visual studio which is my current deployment method. I do see in my build output folder it does create a config file but my deployment method is to take .dll file that is created and drop that into the GAC and then activate the feature using the stsadm tool so by the look of things the config file isn’t used. Any help would be great Thanks Mark
SUG Anonymous User at 1/29/2008 8:01 PM
You must sign in to rate content.
(Unrated)

Re: Using a Config File for Windows SharePoint Services Timer Jobs

You can use the web.config file of your sharepoint web app too - see http://knrs.blogspot.com/2008/01/sharepoint-read-webconfig-inside-timer.html
SUG Anonymous User at 1/22/2008 3:38 PM
You must sign in to rate content.
(Unrated)

Re: Using a Config File for Windows SharePoint Services Timer Jobs

You can use the web.config file of your sharepoint web app too - see http://knrs.blogspot.com/2008/01/sharepoint-read-webconfig-inside-timer.html
SUG Anonymous User at 1/22/2008 3:38 PM
You must sign in to rate content.
(Unrated)

Config file for SharePoint Feature

Hi Not sure if you will be able to help me but my main question is how do you attach a config file to a SharePoint Feature? I have created a timed job, every couple of minutes it connects to a web service to pull data into some lists within a site collection. When I move this timed job to another environment (say from development to test) it connects to a different web service so I want to have a config file so I can modify the connection to the web service without having to build the project again in visual studio which is my current deployment method. I do see in my build output folder it does create a config file but my deployment method is to take .dll file that is created and drop that into the GAC and then activate the feature using the stsadm tool so by the look of things the config file isn’t used. Any help would be great Thanks Mark
SUG Anonymous User at 1/29/2008 8:01 PM
You must sign in to rate content.
(Unrated)

Re: Re: Using a Config File for Windows SharePoint Services Timer Jobs

The reason I wouldn't point this to the main config file is for objects that use the Provider Model that look up on the current web.config.  The best example would be the membership provider.
Mike Parrill at 3/18/2008 5:33 PM
You must sign in to rate content.
(Unrated)

Re: Using a Config File for Windows SharePoint Services Timer Jobs

I tried creating a owstimer.exe.config file under 12\bin but the job is not picking up that config file when i do ConfigurationManager.ConnectionStrings[0].ConnectionString
SUG Anonymous User at 6/5/2008 2:39 PM
You must sign in to rate content.
(Unrated)

Custome timer jobs to run an .exe file

I need to run an exe file using sharepoint custome timer jobs.
can you briefly explain  me how can i do this.i knew that i have to use spjobdefination class,spscheduler class and spminitescheduler classes.i don't know proper way to do this.
Thanks in advance.
SUG Anonymous User at 3/10/2009 3:17 AM
You must sign in to rate content.
(Unrated)

Leave a Comment

You must be logged in to post a comment.
Contributor
Mike Parrill
Senior Developer
SusQtech
Stephens City, VA

Search This Blog

 

© 2010 SusQtech. All rights reserved.
Powered by SharePoint Server 2007 and using the MemberToMember SharePoint Add-On for social media capabilities.