Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get connection string from app.config in another class library project?

Tags:

c#

asp.net

how do I get the connection string from app.config in another "class library project"

in the same class library I can use this code :

 DAL.Properties.Settings.Default.BayrueConnectionString;

but the issue is that I cannot get it from my web app.

thanks enter image description here

like image 763
HAJJAJ Avatar asked Dec 05 '25 15:12

HAJJAJ


1 Answers

I think there is no more elegant way than this. Add a static helper method to your class library which returns it.

public sealed class Helper
{
    private Helper()
    {
    }

    public static string GetBayrueConnectionString()
    {
        return DAL.Properties.Settings.Default.BayrueConnectionString;
    }
}
like image 148
Tim Schmelter Avatar answered Dec 08 '25 04:12

Tim Schmelter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!