简体   繁体   中英

access app config from different project in an application

I have tested to retrieve "configsection" data from app config using c# and it works fine. However, I am facing problem to access these configuration from a different project code. My application is build up of several projects as a bundle. if the app config is in the main project and i want to access that/want to write that from code of another project, how to do that please? I have tried and it throwings errors like as follows:

An error occurred creating the configuration section handler for XXXXX: Could not load type 'XXXXX.XXXXXXX' from assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. (F:\\XXXX\\XXXXX.XXXXX\\bin\\Release\\XXXX.XXXXX.XXXX.exe.Config line 4)

Try to create a class in your main project from which you will get all the items from app config.

From other projects, call this method and get the desired property.

Not sure if you would be able to access it directly.

One way would be to pass the required values as parameters to the instances created from a different project.

I would also like to know if it would be possible to access it directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM