a little help with application setting?! [ConfigurationErrorsException!]

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • giddy

    a little help with application setting?! [ConfigurationErrorsException!]

    Hi ,
    I'm probably just doing something a little silly.
    I get a System.Configur ation.Configura tionErrorsExcep tion!

    This is my config file:
    <configSections >
    <section name="qConfig" type="QuickBuil d.QConfig , QuickBuild" />
    </configSections>
    <qConfig
    PathToDevEnv="D :\Microsoft Visual Studio 8\Common7\IDE\d evenv.exe"
    ShellBuild="fal se"
    ShellUpgrade="f alse"
    />

    This is the code:
    namespace QuickBuild
    {
    public class QConfig : ConfigurationSe ction
    {
    [ConfigurationPr operty("PathToD evenv", IsRequired = true)]
    public string PathToDevenv
    {
    get { return (string)base["PathToDeve nv"]; }
    }
    [ConfigurationPr operty("ShellBu ild",IsRequire d = true)]
    public bool ShellBuild
    {
    get { return (bool)base["ShellBuild "]; }
    }
    [ConfigurationPr operty("ShellUp grade",IsRequir ed = true)]
    public bool ShellUpgrade
    {
    get { return (bool)base["ShellUpgra de"]; }
    }
    }
    }

    And i get a *ConfigurationE rrorsException* when i do this:
    QConfig cfg = ConfigurationMa nager.GetSectio n("qConfig") as QConfig;
    With:"An error occurred creating the configuration section handler for
    qConfig: Could not load type 'QuickBuild.QCo nfig ' from assembly
    'QuickBuild' "

    I'm working with C# 2.0 under .NET 2.0

    Thanks so much
    Gideon

  • DeveloperX

    #2
    Re: a little help with application setting?! [ConfigurationEr rorsException!]

    On 23 Mar, 07:31, "giddy" <gidisr...@gmai l.comwrote:
    Hi ,
    I'm probably just doing something a little silly.
    I get a System.Configur ation.Configura tionErrorsExcep tion!
    >
    This is my config file:
    <configSections >
    <section name="qConfig" type="QuickBuil d.QConfig , QuickBuild" />
    </configSections>
    <qConfig
    PathToDevEnv="D :\Microsoft Visual Studio 8\Common7\IDE\d evenv.exe"
    ShellBuild="fal se"
    ShellUpgrade="f alse"
    />
    >
    This is the code:
    namespace QuickBuild
    {
    public class QConfig : ConfigurationSe ction
    {
    [ConfigurationPr operty("PathToD evenv", IsRequired = true)]
    public string PathToDevenv
    {
    get { return (string)base["PathToDeve nv"]; }
    }
    [ConfigurationPr operty("ShellBu ild",IsRequire d = true)]
    public bool ShellBuild
    {
    get { return (bool)base["ShellBuild "]; }
    }
    [ConfigurationPr operty("ShellUp grade",IsRequir ed = true)]
    public bool ShellUpgrade
    {
    get { return (bool)base["ShellUpgra de"]; }
    }
    }
    >
    }
    >
    And i get a *ConfigurationE rrorsException* when i do this:
    QConfig cfg = ConfigurationMa nager.GetSectio n("qConfig") as QConfig;
    With:"An error occurred creating the configuration section handler for
    qConfig: Could not load type 'QuickBuild.QCo nfig ' from assembly
    'QuickBuild' "
    >
    I'm working with C# 2.0 under .NET 2.0
    >
    Thanks so much
    Gideon
    No constructor?

    Comment

    • DeveloperX

      #3
      Re: a little help with application setting?! [ConfigurationEr rorsException!]

      On 23 Mar, 13:59, "DeveloperX " <nntp...@operam ail.comwrote:
      On 23 Mar, 07:31, "giddy" <gidisr...@gmai l.comwrote:
      >
      >
      >
      >
      >
      Hi ,
      I'm probably just doing something a little silly.
      I get a System.Configur ation.Configura tionErrorsExcep tion!
      >
      This is my config file:
      <configSections >
      <section name="qConfig" type="QuickBuil d.QConfig , QuickBuild" />
      </configSections>
      <qConfig
      PathToDevEnv="D :\Microsoft Visual Studio 8\Common7\IDE\d evenv.exe"
      ShellBuild="fal se"
      ShellUpgrade="f alse"
      />
      >
      This is the code:
      namespace QuickBuild
      {
      public class QConfig : ConfigurationSe ction
      {
      [ConfigurationPr operty("PathToD evenv", IsRequired = true)]
      public string PathToDevenv
      {
      get { return (string)base["PathToDeve nv"]; }
      }
      [ConfigurationPr operty("ShellBu ild",IsRequire d = true)]
      public bool ShellBuild
      {
      get { return (bool)base["ShellBuild "]; }
      }
      [ConfigurationPr operty("ShellUp grade",IsRequir ed = true)]
      public bool ShellUpgrade
      {
      get { return (bool)base["ShellUpgra de"]; }
      }
      }
      >
      }
      >
      And i get a *ConfigurationE rrorsException* when i do this:
      QConfig cfg = ConfigurationMa nager.GetSectio n("qConfig") as QConfig;
      With:"An error occurred creating the configuration section handler for
      qConfig: Could not load type 'QuickBuild.QCo nfig ' from assembly
      'QuickBuild' "
      >
      I'm working with C# 2.0 under .NET 2.0
      >
      Thanks so much
      Gideon
      >
      No constructor?- Hide quoted text -
      >
      - Show quoted text -
      Ditch that idea, having a dumb ass moment. For some reason I suddenly
      thought no constructor was the same as a private constructor,
      forgetting everything I knew about OO :/

      First the class is in the QuickBuild assembly and compiles? I've
      copied config files from other projects and forgotten to update the
      assembly part while remembering to update the class name.
      Second have you tried setting all the attributes to IsRequired=fals e?
      I've been desperately scanning for something in the wrong case.

      Comment

      • giddy

        #4
        Re: a little help with application setting?! [ConfigurationEr rorsException!]

        Hi ,
        Ditch that idea, having a dumb ass moment. For some reason I suddenly
        thought no constructor was the same as a private constructor,
        forgetting everything I knew about OO :/
        haha , lol, i saw your other constructor post.
        First the class is in the QuickBuild assembly and compiles? I've
        copied config files from other projects and forgotten to update the
        assembly part while remembering to update the class name.
        Yes , it does!!
        Second have you tried setting all the attributes to IsRequired=fals e?
        I've been desperately scanning for something in the wrong case.
        I removed all the IsRequired attributes after reading this:


        but now , regardless of whether i have Isrequired or not , the
        following happens:
        QConfig cfg = ConfigurationMa nager.GetSectio n("QConfig") as QConfig;
        Debug.Print(cfg .PathToDevEnv);

        I get a null reference exception , cfg turns out NULL! =S!

        App.Config is fine , everything is defined!

        Could you plz help!

        thanks so much
        Gideon

        Comment

        • DeveloperX

          #5
          Re: a little help with application setting?! [ConfigurationEr rorsException!]

          On 23 Mar, 19:09, "giddy" <gidisr...@gmai l.comwrote:
          Hi ,
          >
          Ditch that idea, having a dumb ass moment. For some reason I suddenly
          thought no constructor was the same as a private constructor,
          forgetting everything I knew about OO :/
          >
          haha , lol, i saw your other constructor post.
          >
          First the class is in the QuickBuild assembly and compiles? I've
          copied config files from other projects and forgotten to update the
          assembly part while remembering to update the class name.
          >
          Yes , it does!!
          >
          Second have you tried setting all the attributes to IsRequired=fals e?
          I've been desperately scanning for something in the wrong case.
          >
          I removed all the IsRequired attributes after reading this:http://doronsharp.spaces.live.com/?_...ew=1&_c11_Blog...
          >
          but now , regardless of whether i have Isrequired or not , the
          following happens:
          QConfig cfg = ConfigurationMa nager.GetSectio n("QConfig") as QConfig;
          Debug.Print(cfg .PathToDevEnv);
          >
          I get a null reference exception , cfg turns out NULL! =S!
          >
          App.Config is fine , everything is defined!
          >
          Could you plz help!
          >
          thanks so much
          Gideon
          Ha, yes. I feel a bit silly.

          It's a bit complicated but I run 2.0 at home and 1.1 in the office.
          Using the enterprise library it's fairly straight forward to deal with
          these issues, but I wanted to test it under 2, so had to wait until
          this evening. Anyway. I can replicate your error and I'll try and work
          towards a solution (part of my dn2 education as it were).
          Under 1.1 this sort of thing is commonly caused when the enterprise
          library can't resolve the location of the object.
          Things to keep in mind. The config file has to have a specific name,
          exename.config iirc.
          The config class must be fully qualified in the config.
          There's an issue under 1.1 at least where you sometimes have to quit
          VS and delete all the files and rebuild to get it to work.
          By default it won't automatically copy the config file to the output
          directory.
          There's a config path that needs to be set under 1.1, will test that
          tomorrow under 2.
          I've tried most of the above to no avail so far :/

          I'm sure someone more experienced than me will pop along shortly :)

          I'm off out for a late night tipple with a friend, so I'll give it
          another shot tomorrow (at the code, not the vodka ;) (unless the code
          won't work!))


          Comment

          • giddy

            #6
            Re: a little help with application setting?! [ConfigurationEr rorsException!]

            hi ,

            Thank you so much for your concern. My internet connection broke down
            for a few days so i was'nt able to reply.

            Ha, yes. I feel a bit silly.
            >
            It's a bit complicated but I run 2.0 at home and 1.1 in the office.
            Using the enterprise library it's fairly straight forward to deal with
            these issues, but I wanted to test it under 2, so had to wait until
            this evening. Anyway. I can replicate your error and I'll try and work
            towards a solution (part of my dn2 education as it were).
            Under 1.1 this sort of thing is commonly caused when the enterprise
            library can't resolve the location of the object.
            Things to keep in mind. The config file has to have a specific name,
            exename.config iirc.
            acutally i found out that , one needs to add App.Config and then VS
            replaces App with the application name and <.exeand puts in in the
            output directory.
            The config class must be fully qualified in the config.
            There's an issue under 1.1 at least where you sometimes have to quit
            VS and delete all the files and rebuild to get it to work.
            By default it won't automatically copy the config file to the output
            directory.
            There's a config path that needs to be set under 1.1, will test that
            tomorrow under 2.
            I've tried most of the above to no avail so far :/
            Same here , i tried it all. Nothing.
            I'm sure someone more experienced than me will pop along shortly :)
            >
            I'm off out for a late night tipple with a friend, so I'll give it
            another shot tomorrow (at the code, not the vodka ;) (unless the code
            won't work!))
            Haha ! lol

            its ok now , you've probably guessed by "shell build" i'm going to
            fiddle with the registry , so i decided to put my configuration in the
            registry too. (under HKLM\SOFTWARE)

            I did pursue the app configuration mechanism because i dont hardly
            know anything about it ,(i'm self taught =P ) i have a very serious
            app that will need app configuration soon so if you or anyone knows of
            a good example please post it here! This app (QuickBuild) is a small
            little pet project i'm on because my stupid high school exams are
            going on.(i hate high school =S )

            Thanks again

            Gideon
            [Damn the google groups =X , this is the second time i'm posting this!
            glad i saved it somewhere first (i have to do that when i'm on google
            grps sometimes! =S)]

            Comment

            Working...