[Mono-osx] ConfigurationErrorsException loading user settings (duplicate key)

d_v dan.vandermolen at figpsoft.com
Wed Jan 21 10:40:48 EST 2009


Hi and thanks Matt.

I am using a "config" file called: <MyUploader_App>.exe.config in my Windows
Form Application .exe root path.   
It is created automagically by VS 2005.NET.
I experienced the errors on Mon0 2.2_5 (latest) version on Mac OS X 10.5.6

The .exe when running on Mono fails before I even read the config file
settings myself.
It fails when I instantiate (if that's the right word) in Form1() code
block, a global web service variable with the lines:

public Form1()
        {
        InitializeComponent();     
        MyWebService = new MyUploaderService();    // Fails Here:    // load
web service (global variable)
        }



Here is the "config" file contents that fail:
///////////////////////////

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="MyUploader_App.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"
/>
        </sectionGroup>
        <sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="MyUploader_App.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <MyUploader_App.Properties.Settings>
            <setting name="UserID" serializeAs="String">
                <value>MyUserID</value>
            </setting>
            <setting name="Password" serializeAs="String">
                <value>MyPassword</value>
            </setting>
            <setting name="Install_cod" serializeAs="String">
                <value>1</value>
            </setting>
            <setting
name="MyUploader_App_UploaderService_ClientUploaderService"
                serializeAs="String">
               
<value>https://www.MyWebSite.net/TestWS/UploaderService.asmx</value>
            </setting>
        </MyUploader_App.Properties.Settings>
    </applicationSettings>
    <userSettings>
        <MyUploader_App.Properties.Settings>
            <setting name="UploadTime" serializeAs="String">
                <value>09:30</value>
            </setting>
            <setting name="Domain" serializeAs="String">
                <value>MyDomain</value>
            </setting>
        </MyUploader_App.Properties.Settings>
    </userSettings>
</configuration>


I read the .exe.config file like so later on:  
    Properties.Settings.Default.Install_cod;




Matt Emson wrote:
> 
> d_v wrote:
> 
> How are you reading your settings? What does your config file look like? 
> So if you have this file saved as "app.config":
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>   <appSettings>
>     <add key="MySettingKey" value="My setting value"/>
>   </appSettings>
> </configuration>
> 
> I don't know how the Mono compiler handles config files, but if you do 
> the above in a C#project and then compile it, it'll get moved and 
> renamed to "YourExeName.exe.config".
> 
> 
> If you then use something like:
> 
> class TestConfig
> {
>   public static void Main()
>   {
>     string setting = 
> System.Configuration.ConfigurationManager.AppSettings["MySettingKey"];
>     System.Console.WriteLine(setting);
>   }
> }
> 
> Does that fail? That's a pretty basic thing that should work, if it 
> doesn't.
> 
> If you are speaking about Web based stuff, surely it should be 
> "Web.config"? AFAIK this never gets moved or renamed.
> 
> 
> M
>> I experienced the same thing. Thanks for your solution!
>>
>> I have had mixed results:
>> In two different test applications, with a web service reference, I seem
>> to
>> be OK with both user and application configuration settings when creating
>> a
>> new web service instance.
>>
>> But my main application will fail, with a web service reference, if I
>> have
>> mixed scopes when creating a new instance of the web service. It was
>> still
>> an error even when I removed all other configuration settings.  But when
>> I
>> changed the last remaining web service reference scope to "User" as you
>> suggested, it worked. 
> 
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
> 
> 

-- 
View this message in context: http://www.nabble.com/ConfigurationErrorsException-loading-user-settings-%28duplicate-key%29-tp20559897p21585661.html
Sent from the Mono - OSX mailing list archive at Nabble.com.



More information about the Mono-osx mailing list