linq to sql use app.config file

jassie

Well-known member
Joined
Nov 13, 2012
Messages
61
Programming Experience
1-3
I am having a linq to sql problem with a C# 2010 windows form application when it is changed to a dll and accessed by other applications. The purpose of the calling the code as a dll is for performance reasons and to share the code accross multiple applications.
When the application is on its own, it runs fine.
Basically when the linq to sql was dragged to the desktop, a default linq to sql connection was setup by the .net framework. However I changed the *.designer.cs to use the system.configuration namespace,
added a reference to the system.configuration namespace, and changed the default linq to sql connection to use the database connection obttained in app.config file. I also removed any refernces to the default database connections in the the 'properties or 'settings' section for each project file folder.
Now the problem is the default setting values to the database are reset by the .net framework. Thwe values in the app.config file are no longer being used.
Can you show me code, point me to a reference, and/or tell how I can make this application is the connection string values in the app.config file again?
 
Basically, you've broken it by doing things that you shouldn't have done. You should pretty much never be editing a designer file yourself. All you needed to do was copy the connection string element from the config file of the DLL into the config file of any application referencing that DLL and then edit the connection string in the application to whatever you wanted it to be at the time. That's it, that's all. You don't need any code at all and you certainly don't need to edit a designer code file. I recommend that you create a new project and just copy the bits and pieces over from the old one.
 
Back
Top Bottom