Event Handler Settings

I recently created an event handler to process forms from a Form Library.  The Event handler is used to handle new items being added to the library, and save a portion of the form to a file share for another application to process.

In order to follow good programming habits, I figured I should put the fileshare location in a config file somewhere where we can update it in the future without having to crack open the code to modify a hard-coded path location.  I added an AppSettings section to the web.config file for the SharePoint website that I was working with, but found that my code would never pickup the settings.

I know the event handler assembly is added to the GAC, but figured it was running under the application domain for the SharePoint site and would use those settings..  I was wrong.  The problem now is where to put those settings…

I found that the machine.config file under in the C:WINDOWSMicrosoft.NETFrameworkv1.1.4322CONFIG folder has an AppSettings section that is commented out.  If you uncomment the section and add your setting there, they will be available when the event handler is called.

 

kick it on SharePointKicks.com

Leave a Reply