Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Unrecognized configuration section userSettings
ChrisB
#1 Posted : Monday, July 27, 2015 9:11:04 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2014(UTC)
Posts: 8
Location: United Kingdom

Thanks: 2 times
Hi,

I have a projec t that has user settings (i.e. in the Settings.Designer.cs), when NCrunch tries to run its unit tests it fails with the following,

SetUp : System.Configuration.ConfigurationErrorsException : Configuration system failed to initialize
----> System.Configuration.ConfigurationErrorsException : Unrecognized configuration section userSettings. (C:\...\AppData\Local\Remco_Software_Ltd\nCrunch.TestRunner.AppDom_Url_q2piuozo0uftcc2pz5zv15hpilzfpoqk\2.15.0.9\user.config line 3)
at System.Configuration.ConfigurationManager.PrepareConfigSystem()
at System.Configuration.ConfigurationManager.RefreshSection(String sectionName)
at System.Configuration.ClientSettingsStore.ReadSettings(String sectionName, Boolean isUserScoped)
at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties)
at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)
at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
at System.Configuration.SettingsBase.get_Item(String propertyName)
at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
...\Properties\Settings.Designer.cs:line 31

I've changed NCrunch to use the compatibility mode settings and I'm still getting the error.

Any ideas as to how to get NCrunch to use the project user settings? I'm using NCrunch v2.15 with Visual Studio 2013.
Thanks,
Chris.
Remco
#2 Posted : Monday, July 27, 2015 11:34:34 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Chris,

Thanks for sharing this issue.

You'll have to forgive me but I'm not very familiar with this method of declaring config settings. Can you share any more details about the code involved in this and how it's expected to behave? Is it possible that this is simply a file that hasn't been included in the NCrunch workspace? http://www.ncrunch.net/documentation/considerations-and-constraints_implicit-file-dependencies.
ChrisB
#3 Posted : Monday, July 27, 2015 12:11:11 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2014(UTC)
Posts: 8
Location: United Kingdom

Thanks: 2 times
In the solution explorer for a project there is a properties item which has a Setttings.settings item. You can add a setting by double clicking on the Settings.settings item. This brings up a settings window where you can view and add application settings. Visual Studio automatically generates a c# file containing your settings called Settings.Designer.cs.

In your code you can access the settings in your code with

var setting = Properties.Settings.Default.SettingName;

NCrunch is failing when it trys to access the setting with a ConfigurationErrorsException : Unrecognized configuration section userSettings.

Settings.Designer.cs is a file that the project knows about (since it generated it and shows it in the project), so I would guess that NCrunch would know about it for its workspace - although I could be wrong, I haven't used NCrunch that much.

Thanks,
Chris.
Remco
#4 Posted : Monday, July 27, 2015 10:30:15 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Chris,

Thanks for sharing these extra details. I've done a little experimentation on this side, and I've come up with a theory on why this may be happening for you.

I think that the root of the problem is actually in the arrangement of configuration in your .config files, rather than the Settings file that is accessing them.

A common pattern in config files is to chain .config files together (using 'configSource' or something similar) to keep them tidy. For example, you may have a web.config that includes a user.config, which includes a db.config, etc.

NCrunch is unable to traverse these dependencies as they aren't always represented in the project file. This means that you may well have a .config file somewhere that is not included in your project, but is being referenced by another .config file. When .NET attempts to load configuration, it cannot find the dependency and fails with an error.

Do you have any .config files related to your projects that are not included in the project file?
ChrisB
#5 Posted : Tuesday, July 28, 2015 7:59:16 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2014(UTC)
Posts: 8
Location: United Kingdom

Thanks: 2 times
Hi,

I have got the app.config file that has the setting as follows,

<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="....Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
...
<userSettings>
<....Properties.Settings>
<setting name="LastScmLower" serializeAs="String">
<value>0</value>
</setting>
</....Properties.Settings>
</userSettings>
</configuration>

This file is included in the project. I've tried manually adding it to the NCrunch config for the project but it didn't make any difference.
Thanks,
Chris.
Remco
#6 Posted : Tuesday, July 28, 2015 11:20:00 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Chris,

Do you notice any difference if you set up NCrunch in compatbility mode? http://www.ncrunch.net/documentation/troubleshooting_compatibility-mode.
ChrisB
#7 Posted : Tuesday, July 28, 2015 12:36:57 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2014(UTC)
Posts: 8
Location: United Kingdom

Thanks: 2 times
Hi, I've tried the compatibility mode and it didn't make any difference.
Chris.
Remco
#8 Posted : Wednesday, July 29, 2015 12:23:00 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks Chris.

I'm wondering if it may be possible to take a look at the file being referenced in the exception: C:\...\AppData\Local\Remco_Software_Ltd\nCrunch.TestRunner.AppDom_Url_q2piuozo0uftcc2pz5zv15hpilzfpoqk\2.15.0.9\user.config

Would you be able to try running your test with a debugger attached to see if you can get a snapshot of the file in the state that .NET tries to load it? I wonder if something is corrupting the file. Is there anything that appears to be wrong with the file in the form that it is loaded?
1 user thanked Remco for this useful post.
ChrisB on 7/29/2015(UTC)
ChrisB
#9 Posted : Wednesday, July 29, 2015 8:07:29 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2014(UTC)
Posts: 8
Location: United Kingdom

Thanks: 2 times
Hi,

I looked at the user.config and it was for another project in another solution (that I also have configured with NCrunch). I deleted the file and ran the tests again and they are alll passing and the user.config looks sensible.

Thanks very much for all your help.
Chris.
ChrisB
#10 Posted : Wednesday, July 29, 2015 8:46:59 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2014(UTC)
Posts: 8
Location: United Kingdom

Thanks: 2 times
I quite often have two or more solutions open in separate instances of Visual Studio. Does NCrunch support this way of working? I've been trying it and have had issues like with the user.config and also with errors like the following,

System.Configuration.ConfigurationErrorsException : Failed to save settings: It is an error to use a section registered as allowExeDefinition='MachineToRoamingUser' beyond the roaming user config, in the local user config. (C:\Users\...\AppData\Local\Remco_Software_Ltd\nCrunch.TestRunner.AppDom_Url_q2piuozo0uftcc2pz5zv15hpilzfpoqk\2.15.0.9\user.config line 9)
----> System.Configuration.ConfigurationErrorsException : It is an error to use a section registered as allowExeDefinition='MachineToRoamingUser' beyond the roaming user config, in the local user config. (C:\Users\...\AppData\Local\Remco_Software_Ltd\nCrunch.TestRunner.AppDom_Url_q2piuozo0uftcc2pz5zv15hpilzfpoqk\2.15.0.9\user.config line 9)

Thanks for all your help,
Chris.
Remco
#11 Posted : Wednesday, July 29, 2015 11:12:38 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks Chris.

NCrunch itself does support multiple VS instances side-by-side. It can even work with multiple VS instances of the same solution. Care is taken to separate the workspaces between VS instances.

However, it's possible to run into problems where absolute file paths are involved. If you have two projects (in the same solution or different solutions) that both point to the same file on disk during their build or test run, then you'll likely have problems like the one you're experiencing with the user.config file.

The path 'C:\Users\...\AppData\Local\Remco_Software_Ltd\nCrunch.TestRunner.AppDom_Url_q2piuozo0uftcc2pz5zv15hpilzfpoqk\2.15.0.9\' isn't declared anywhere by NCrunch. It looks like this is some kind of shadow-copy directory being created by the runtime itself, using the nCrunch.TestRunner assembly name and version for the naming.

I'm afraid that I'm not sure which part of the runtime could be responsible for behaviour, but I recommend checking the config files involved to see if they have any settings regarding shadow copy or anything similar. The default setup for NCrunch itself is to avoid any kind of shadow-copying in the runtime, as NCrunch already does this with its workspacing. It is also possible that there might be something in your machine.config that is causing this.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.064 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download