2

I have a class library and my other projects are using it. And also i have some connection strings. i want to use them from just class lib's App.config file. But when i use ConfigurationManager in my class lib for reading connection strings, program looks my current project's App.config or Web.config files.

How can i use connection strings from class lib's App.config file?

Thanks in advance

1

3 Answers 3

1

I think you need a Xml file in your class library. You should read your connection strings from it.

Sign up to request clarification or add additional context in comments.

Comments

0

Copy them from the class lib's config file to the application's config file. See .Net app.config in library project

2 Comments

thanks for your answer, but i want to write conenction strings to only one config file.
Then you can use your own files (like myConf.xml) and store connection string there. But i fyou want to use App.config, then it has to be in yout end application
0

You have to provide a connection string in the end application.

Say you have a library.dll and application.exe

Classes in application.exe use library.dll. And classes in library.dll need connection string from App.config. Then you have to provide the connection string in App.config of your application.exe.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.