Configuration files
-
Hi! I have a project say 'project1'. I have added some configuration sections to app.config file. The configuration sections contain initialization data for various objects. The objects read those configration information to initialize themselves. It works correctly. But when i create a class library of this project and add it to a web application the objects become unable to read thier configuration data from app.config file. So when i add that data to the web.config file it works fine. But i want my objects be able to read configuration data from the app.config file. How can i do that? Thanks.
-
Hi! I have a project say 'project1'. I have added some configuration sections to app.config file. The configuration sections contain initialization data for various objects. The objects read those configration information to initialize themselves. It works correctly. But when i create a class library of this project and add it to a web application the objects become unable to read thier configuration data from app.config file. So when i add that data to the web.config file it works fine. But i want my objects be able to read configuration data from the app.config file. How can i do that? Thanks.
Hi peshawarcoder, To me, this sounds like a permission problem / path problem. Could you post the error that it gives ? Cheers,
-
Hi! I have a project say 'project1'. I have added some configuration sections to app.config file. The configuration sections contain initialization data for various objects. The objects read those configration information to initialize themselves. It works correctly. But when i create a class library of this project and add it to a web application the objects become unable to read thier configuration data from app.config file. So when i add that data to the web.config file it works fine. But i want my objects be able to read configuration data from the app.config file. How can i do that? Thanks.
Class libraries cannot have config files. They are libraries of code that become part of the application project itself. Using the normal built-in methods, they must get their settting from the host applications config files, be it app.config for WinForms or web.config for ASP.NET. Outside of that, you'll have to implement your own configuration settings retrieval scheme.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Class libraries cannot have config files. They are libraries of code that become part of the application project itself. Using the normal built-in methods, they must get their settting from the host applications config files, be it app.config for WinForms or web.config for ASP.NET. Outside of that, you'll have to implement your own configuration settings retrieval scheme.
Dave Kreskowiak Microsoft MVP - Visual Basic
Thanks. Your suggestion to implement my own configuration setting retrieval scheme will help me to a great extent. Did you mean to add configuration sections to the web.config file and provide code that my objects use to get information from their respective configuration sections in the web.config file. (I have already done this.) But i want that there should be a separate configuration file from which objects instantiated from the classes in the class library get thier data.
-
Thanks. Your suggestion to implement my own configuration setting retrieval scheme will help me to a great extent. Did you mean to add configuration sections to the web.config file and provide code that my objects use to get information from their respective configuration sections in the web.config file. (I have already done this.) But i want that there should be a separate configuration file from which objects instantiated from the classes in the class library get thier data.
peshawarcoder wrote:
Did you mean to add configuration sections to the web.config file and provide code that my objects use to get information from their respective configuration sections in the web.config file
No. You implement your own configuration manager so that your code can specify which file to open to get configation settings. You can probably start with this[^].
Dave Kreskowiak Microsoft MVP - Visual Basic