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

G

giddy

Hi ,
I'm probably just doing something a little silly.
I get a System.Configuration.ConfigurationErrorsException!

This is my config file:
<configSections>
<section name="qConfig" type="QuickBuild.QConfig , QuickBuild" />
</configSections>
<qConfig
PathToDevEnv="D:\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
ShellBuild="false"
ShellUpgrade="false"
/>

This is the code:
namespace QuickBuild
{
public class QConfig : ConfigurationSection
{
[ConfigurationProperty("PathToDevenv", IsRequired = true)]
public string PathToDevenv
{
get { return (string)base["PathToDevenv"]; }
}
[ConfigurationProperty("ShellBuild",IsRequired = true)]
public bool ShellBuild
{
get { return (bool)base["ShellBuild"]; }
}
[ConfigurationProperty("ShellUpgrade",IsRequired = true)]
public bool ShellUpgrade
{
get { return (bool)base["ShellUpgrade"]; }
}
}
}

And i get a *ConfigurationErrorsException* when i do this:
QConfig cfg = ConfigurationManager.GetSection("qConfig") as QConfig;
With:"An error occurred creating the configuration section handler for
qConfig: Could not load type 'QuickBuild.QConfig ' from assembly
'QuickBuild' "

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

Thanks so much
Gideon
 
D

DeveloperX

Hi ,
I'm probably just doing something a little silly.
I get a System.Configuration.ConfigurationErrorsException!

This is my config file:
<configSections>
<section name="qConfig" type="QuickBuild.QConfig , QuickBuild" />
</configSections>
<qConfig
PathToDevEnv="D:\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
ShellBuild="false"
ShellUpgrade="false"
/>

This is the code:
namespace QuickBuild
{
public class QConfig : ConfigurationSection
{
[ConfigurationProperty("PathToDevenv", IsRequired = true)]
public string PathToDevenv
{
get { return (string)base["PathToDevenv"]; }
}
[ConfigurationProperty("ShellBuild",IsRequired = true)]
public bool ShellBuild
{
get { return (bool)base["ShellBuild"]; }
}
[ConfigurationProperty("ShellUpgrade",IsRequired = true)]
public bool ShellUpgrade
{
get { return (bool)base["ShellUpgrade"]; }
}
}

}

And i get a *ConfigurationErrorsException* when i do this:
QConfig cfg = ConfigurationManager.GetSection("qConfig") as QConfig;
With:"An error occurred creating the configuration section handler for
qConfig: Could not load type 'QuickBuild.QConfig ' from assembly
'QuickBuild' "

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

Thanks so much
Gideon

No constructor?
 
D

DeveloperX

Hi ,
I'm probably just doing something a little silly.
I get a System.Configuration.ConfigurationErrorsException!
This is my config file:
<configSections>
<section name="qConfig" type="QuickBuild.QConfig , QuickBuild" />
</configSections>
<qConfig
PathToDevEnv="D:\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
ShellBuild="false"
ShellUpgrade="false"
/>
This is the code:
namespace QuickBuild
{
public class QConfig : ConfigurationSection
{
[ConfigurationProperty("PathToDevenv", IsRequired = true)]
public string PathToDevenv
{
get { return (string)base["PathToDevenv"]; }
}
[ConfigurationProperty("ShellBuild",IsRequired = true)]
public bool ShellBuild
{
get { return (bool)base["ShellBuild"]; }
}
[ConfigurationProperty("ShellUpgrade",IsRequired = true)]
public bool ShellUpgrade
{
get { return (bool)base["ShellUpgrade"]; }
}
}

And i get a *ConfigurationErrorsException* when i do this:
QConfig cfg = ConfigurationManager.GetSection("qConfig") as QConfig;
With:"An error occurred creating the configuration section handler for
qConfig: Could not load type 'QuickBuild.QConfig ' 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=false?
I've been desperately scanning for something in the wrong case.
 
G

giddy

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=false?
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/?...ogview&_c=BlogPart&partqs=amonth=3&ayear=2007

but now , regardless of whether i have Isrequired or not , the
following happens:
QConfig cfg = ConfigurationManager.GetSection("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
 
D

DeveloperX

Hi ,


haha , lol, i saw your other constructor post.


Yes , it does!!


I removed all the IsRequired attributes after reading this:http://doronsharp.spaces.live.com/?_c11_BlogPart_FullView=1&_c11_Blog...

but now , regardless of whether i have Isrequired or not , the
following happens:
QConfig cfg = ConfigurationManager.GetSection("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!))
 
G

giddy

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
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)]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top