Config Store doesn't work for me.

Aug 31, 2009 at 12:42 PM

I installed this solution. I tried to use it: I crated simple aspx-page:

<%@ Page Language="C#" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C" %>
<%@ Assembly Name="COB.SharePoint.Utilities.ConfigStore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=23afbf06fd91fa64" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="System.ComponentModel" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="COB.SharePoint.Utilities" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(object sender, EventArgs e)
{

    string sAdminEmail = ConfigStore.GetValue("MyApplication", "AdminEmail");

    Response.Write(sAdminEmail);
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page </title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

 

But I get the following message (in translation from russian):

In configuration section appSettings the key 'ConfigStoreCacheDependencyFile' doesn't exist.
In System.Configuration.AppSettingsReader.GetValue(String key, Type type)
   In COB.SharePoint.Utilities.ConfigStore..cctor()

What I do wrong?

Nov 4, 2009 at 4:17 PM

Nothing. The project has a lot of flaws and it simply won't work if you don't alter the code.

This

In configuration section appSettings the key 'ConfigStoreCacheDependencyFile' doesn't exist.

means that he is unable to get the values from the web.config. Even that you have those values in the web config, it wont work.

Cheers

Coordinator
Nov 5, 2009 at 10:33 PM

@antipa,

You need to add several keys to your web.config - this happens by default in most releases (including the current one, 2.1.0.2) but was removed for a couple of releases to suit users deploying to multiple site collections. I assume you're running one of those releases and so didn't get them added for you - in any case, instructions are in the readme.txt file, but for convenience here are the appSettings keys you need:

<add key="ConfigSiteUrl" value="http://www.mySite.com" />
<add key="ConfigWebName" value="" />
<add key="ConfigListName" value="Config Store" />
<add key="ConfigStoreCacheDependencyFile" value="\\myUncPath\folder\ConfigStoreCacheDependency.txt" />

Obviously you'll need to edit for your values. Note there a couple of other steps (e.g. ensuring NTFS permissions for the cache dependency file), so reading the readme.txt is a good idea.

HTH,

Chris.

 

Coordinator
Nov 5, 2009 at 10:34 PM

@jonny666,

I've used the project several times and have heard from many more people using it successfully.

What specifically did you run into?

Thanks,

Chris.

Nov 24, 2009 at 7:40 PM

@Chris,

What should the ConfigStoreCacheDependencyFile value be pointing to? You say to edit it for your values, but is this a new file you create, new folder, etc. and what account should have permissions (and what should those permissions be) to this file?

Thanks.

Coordinator
Nov 25, 2009 at 12:57 PM

@bsimser,

The readme.txt has this:

5. Modify the appSettings config values to suit your environment:
     i)   ConfigStoreSiteUrl - this should be the URL of the site collection which stores the Config Store list. If you are using the 'hierarchical'
            feature with multiple Config Store lists in multiple site collections, this URL will be the 'master' Config Store list.
     ii)  ConfigStoreWebName - specify empty value for root web of site collection, or specify web name if you have moved the Config Store list
   (e.g. to a 'Configuration' web).
  iii) ConfigStoreListName - leave as 'Config Store' unless you have renamed the list.
  iv)  ConfigStoreCacheDependencyFile - this should be a UNC path accessible by all WFEs in your farm, but for a single server deployment
           can be a simple 'C:\folder\ConfigStoreCacheDependency.txt' path. 
6. Set appropriate NTFS/share permissions to ensure the Config Store can write to the file specified in the 'ConfigStoreCacheDependencyFile' key.
 Typically you will need to grant permissions to the app pool identity to do this.

Reading that back, it might not be 100% clear that the ConfigStoreCacheDependency.txt file just needs to be an empty text file which can be written to. Essentially it's used to invalidate the cache across multiple WFEs - watch out for the requirement to have a single UNC path accessible from all WFEs though, some clients might not allow firewall rules for this. I'd love to switch this to a SqlCacheDependency at some point, but ran into issues when I tried this before.

Let me know if you need anything else.

Chris. 

Dec 1, 2009 at 8:21 PM

@Chris: Works fine, thanks. It was a little confusing about what the text file should be but once I set it up and saw it in action I got it. Works great. Thanks!

Mar 11, 2010 at 8:15 PM

@Chris: Could you make some kind of modification to the solution please. Here's the problem. We have a central config site where we deploy the tool but we're using ConfigStore on mulitple site collections. No problem except that when someone who's a site owner (and thus has the ability to activate a feature) activates it on their site, it re-writes the web.config entries and puts in the default \\myUncPath\\ stuff again. This is a problem. I've done a makeshift fix by updating the feature.xml and hiding it from the web UI but I think there should be a more elegant solution.

A few ideas/options:

  • Check web.config and if the settings are already there, leave them alone (maybe the preferred choice) otherwise add them
  • Don't do anything to web.config on feature activation and leave it up to the administrator to manually do this
  • Hide the feature from the web UI so it can only be done on the server

Thanks.

Coordinator
Mar 12, 2010 at 3:35 PM

@Bil,

There's a feature property named 'ApplyWebConfigModifications' which is designed to deal with this - it defaults to true in the latest version, so you should switch it to get the behavior you want. I went backwards and forwards on the right default for this and settled on true on the basis that most installs of this probably only have a single master list. It does definitely need to be switched when using it in 'multiple list' mode though.

Unless I screwed up all this should be in the readme.

Frankly though, I like your suggestion of only adding the entries if they're not there. Not sure why this didn't occur to me, brain cells obviously not firing that day. I'll likely move over to this in a future version but does the feature property give you what you need for now?

Thanks,

Chris.

Jun 29, 2011 at 9:50 PM
Edited Jun 29, 2011 at 9:57 PM

Chris,

I keeping getting this error but I have The key 'ConfigStoreCacheDependencyFile' defined in web.config - any ideas?

I Test method ReminderNoticeJobTest.UnitTest1.GetProperties threw exception:
System.TypeInitializationException: The type initializer for 'COB.SharePoint.Utilities.ConfigStore' threw an exception. ---> System.InvalidOperationException: The key 'ConfigStoreCacheDependencyFile' does not exist in the appSettings configuration section.

 

System.Configuration.AppSettingsReader.GetValue(String key, Type type)
COB.SharePoint.Utilities.ConfigStore..cctor()
COB.SharePoint.Utilities.ConfigStore.GetValue(String Category, String Key)
ReminderNoticeJobTest.UnitTest1.GetProperties() in D:\Development\mvasquez\ReminderTimerJob\ReminderNoticeJobTest\UnitTest1.cs: line 300

 

I am running windows server 2003 x64

 

Michael

Coordinator
Jun 29, 2011 at 10:16 PM

@vmichael,

This is happening because you're running in the context of a unit test, which is not within the scope of IIS/the web.config file. Add the Config Store entries to either the .exe.config file for your unit test framework, or to machine.config if this is a dev machine.

HTH,

Chris.