>>I'v got this in my app.config:
>>
>>
>> add name="ConnString"
>> connectionString="Data Source=MAROIS_MAIN_PC\SQLEXPRESS;Initial Catalog=AppSecurity;Trusted_Connection=Yes "
>> providerName="System.Data.SqlClient"/
>>
>>
>>I'm trying to read it like this:
>>
>>
>>if (_ConnString == string.Empty)
>>{
>> _ConnString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
>>}
>>
>>I get "Object reference not set to an instance of an object"
>>
>>After an hour of trying all manner of things, and no results from Google, I changed it to this:
>>
>> _ConnString = ConfigurationManager.ConnectionStrings[
0].ConnectionString;
>>
>>and it return a string, but this is what gets returned
>>
>>
>>data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
>>
>>
>>What the hell is going on??? What's the right way to do this???
>
>You are using an app.config, but I'm assuming your app isn't seeing it and is reading the web.config. That value that you see is the default connection string that is included in a new web.config file.
It's a WinForms app, not a web app. There's no Web.Config - that I can see
Thing is - I'm using this same app.config in other apps, and I read it the same way. The only difference is the DBML I added to my project, which has a conn string embedded in it. I have the Application Settings property set to False, and there's nothing in Settings.Settings.
The only conn string I can see in my app is in the DBML (not used as above) and app.config.
Another thing. I started this at the office where it worked fine, the brought it home where I'm now seeing this. I unzipped it & ran it, and now it can't see the app.config.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people