AlanS said:
XP on SQL Server and it is greatly desired to have a config file so
as to control some pathnames and control varibales. If I include the
If you use the framework config API this data must be in the app's config
file or in machine.config.
Class library with a project (say a win app), I can read read the
App.Config file from the the class library without any problems. If
That's the intended behaviour.
I try to use a app.config with class library assembly, then code such
as ConfigurationSettings.AppSettings["ErrorLogFile"] no longer
returns any values. In fact, an exception is thrown if i try.
Nope.
The reason is that the AppDomain is created with the name of the config
file, once the AppDomain is created you cannot change the name of the config
file. The default name of the config file is <app file name>.config.
However, if you create a new AppDomain you can tell it to use any config
file you specify, but I don't think that you want to do this!
Is there some way to associate a config file with the class library
assembly? I looked at the documentation on customizing assemblies,
but it is not clear to me how to associate a config file with the
class library assembly.
If all you want to do is to control "some pathnames and control varibales"
then you could create a class with these as public properties and then use
the XmlSerializer class to serialize/deserialize instances of this class to
an XML class. If you are doing this, then you store this file in isolated
storage if the data is associated with a user, or to the application's
folder if the data is not user specific.
Richard