Well, I believe the discussion moved from whether one should store the connection string in the app.config file towards an argument on whether you can associate a config file with a class library. Roy, you claimed that you didn't think that "you can use an app.config w/a class library project". If by "use" you meant associating an app.config file to your class library, in addition to the one associated to the application (and I don't see what else you could have meant), I argue that it can be done. I have done it several times in the past.
-----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Pardee, Roy Sent: Monday, October 02, 2006 5:11 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption But isn't it even simpler to make the class' clients responsible for specifying the connection string? That gets you back down to a single app.config per application, and keeps your class lib uncoupled from its clients. Just my $.02... -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Eddie Lascu Sent: Monday, October 02, 2006 2:05 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption You can place the configuration parameters used by the class library straight into the app.config file of the application that uses the class library, like Dean suggested. There is a downside for doing that. If you use the class library in multiple projects, you will have to replicate the same configuration section over and over again. Instead of doing that, you can have two app.config files and just link them together. >From each application's app.config you can link the app.config of the class library and you don't have any replication. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Dean Cleaver Sent: Monday, October 02, 2006 4:50 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption If you use app.config from a class library, it simply reads the executables app.config - so you can place your values in there and the class library will read it. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Eddie Lascu Sent: Tuesday, 3 October 2006 09:39 To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption You can't use an app.config w/ a class library project, because you cannot run the class library. You can however have one app.config associated with your application (console, win frame, win service) and another app.config associated with your class library (.dll). You can link the class lib's app.config in the app's app.config. There was a limitation in VS2003 where you could link only one class lib app.config file in an app's app.config and another limitation where you could only have up to two files linked like this (the class lib's app.config was not allowed to link another class lib app.config file). Obviously, when you deploy the application, you need to do a lot of renaming. I have done this in the past and is not big deal. I haven't checked whether the limitation still exists in VS2005. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Pardee, Roy Sent: Monday, October 02, 2006 4:15 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption I don't think you can use an app.config w/a class library project. You can probably have your .dll seek out and/or create a particular text file for users to set up conn strings in, but my advice would be to code your class to accept connection strings from clients, and make encrypting those the clients' problem. The clients can use the stock app.config goo, so it's not much of a hardship on them. HTH, -Roy -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Hevel, Shawn Sent: Monday, October 02, 2006 7:31 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption There is but can you still use an App.Config file in a class. I've tried it but when I add the code to read the settings I continue to get null. I am successful in reading an App.Config file in a Console application but not a Class Project. Shawn Hevel, API, AIT Lead Programmer Analyst Information Technology Department South Carolina Farm Bureau Insurance Companies Phone: (803) 936-4331 Fax: (803) 936-4629 Work Email: [EMAIL PROTECTED] Home Email: [EMAIL PROTECTED] -----Original Message----- From: Phil Sayers [mailto:[EMAIL PROTECTED] Sent: Monday, October 02, 2006 10:26 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption if this is for framework 2.0... isn't there a new connectionstrings section in the config files?...i'd swear i've seen something about automagic encryption in certain places in the config files. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Eddie Lascu Sent: Monday, October 02, 2006 9:56 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption Yes, windows authentication is the way to go. However, if for whatever reasons you still want the connection string somewhere else, look at the Enterprise Library - Data Access Application Block. There is a sample there that shows you how to store the connection string in the app.config file (actually it is in the dataconfiguration.config) and encrypt that section of the configuration file. Regards, Eddie -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Phil Sayers Sent: Monday, October 02, 2006 9:10 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] SQL connection information - Encryption keep the database server name only in the config file. ...optionally keep the database name in the config fie. use windows integrated authentication to connect to the sql server. with the sql account options, you can set a default database...or make sure you use 4 part naming to explicitly specify which database your sql code is using... -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Hevel, Shawn Sent: Monday, October 02, 2006 9:01 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: [ADVANCED-DOTNET] SQL connection information - Encryption I have a class that needs to connect to a SQL Server Database. How can I encrypt my connection information without hard-coding the connection string in the class? I thought about using the App.Config file but I don't think that is allowed because the class is not in an executable project? Is that correct statement? What would be the best way to hide this connection information using encryption? Thanks for the help. Shawn Hevel, API, AIT Lead Programmer Analyst Information Technology Department South Carolina Farm Bureau Insurance Companies Phone: (803) 936-4331 Fax: (803) 936-4629 Work Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> Home Email: [EMAIL PROTECTED] =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com