-1

I know this has been answered elsewhere, but I can't get the basics to run... Regardless of the application purpose (which is obvious)

        private void btnSave_Click(object sender, EventArgs e)
    {
        // these are *internal* properties of the NET appilcation
        FileSystemWatcher.Properties.Settings.Default.MailServer = Convert.ToString(txtMailServer);
        FileSystemWatcher.Properties.Settings.Default.ServerPort = Convert.ToInt16(txtServerPort.Text);
        FileSystemWatcher.Properties.Settings.Default.Subject = Convert.ToString(txtSubject);
        FileSystemWatcher.Properties.Settings.Default.MessageFrom = Convert.ToString(txtMessageFrom);
        FileSystemWatcher.Properties.Settings.Default.MessageTo = Convert.ToString(txtMessageTo);
        FileSystemWatcher.Properties.Settings.Default.Save();
    }

First issue is that I get a bunch of these exceptions when I hit this code...

Exception thrown: 'System.Security.SecurityException' in mscorlib.dll

No other runtime errors I can see... The app.config appears to be structured correctly - using Project-Add New Item.. etc and inspecting the app.config contents. But the SAVE function listed above - doesn't save any changes I may make.

thanks

M C
  • 61
  • 7
  • Which line is throwing the exception? – Tdorno Feb 05 '17 at 05:17
  • How do you know app.config is throwing error? – Hameed Syed Feb 05 '17 at 05:24
  • It appears (after setting a breakpoint and steppig through), that each of these is... xxxx.Properties.Settings.Default.MailServer = xxvaluexx – M C Feb 05 '17 at 05:43
  • I commented out all the lines except the first and the 'save()... Still get a bunch of the exceptions - maybe 20+ No pop-up errors or crash-stop, just exceptions in the debug output – M C Feb 05 '17 at 06:11
  • 1
    Not sure I understand. What is `FileSystemWatcher`? Is it your class or `System.IO.FileSystemWatcher`? – Tomer Feb 05 '17 at 09:31

1 Answers1

0

I discovered my folly... BEFORE I even knew there was a FileSystemWatcher class - I had already named my project ... you guessed it.. FileSystemWatcher ! So the namespace assumed I was talking about the class - not the app framework !

No compile errors of course! THANKS to all the helpers! Forgive me - I'm learning!

M C
  • 61
  • 7