4

I have a .NET 3.0 Winform Application with a corrupt user.config file causing system config errors.

I wanted to improve handle these errors, similar to how it's done in this example on CodeProject.

To use '

However, when I try and use the 'ConfigurationErrorsException' to get the name of corrupted file I receive the following error:

The type or namespace name 'ConfigurationErrorsException' could not be found (are you missing a using directive or an assembly reference?)  

I have only seen this error previously where there were .NET framework conflicts. The project has the target framework .NET 3.0. The ConfigurationErrorsException was added in 2.0, so I didn't think there would be a framework conflict there.

The version 3.0 documentation is lacking compared to other versions and does say:

The current value is not one of the EnableSessionState values.

Which I'm not entirely sure what that implies (the documentation for EnableSessionState lead to more confusion rather than less).

  • Why does the program fail to build, with a type or namespace missing error?
  • Is this related to targeting .NET 3.0?
  • If so, Is there an alternative for .NET 3.0?

EDIT: I have made sure to include 'using System.Configuration' at the top of my page. The total list of usings is:

using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Threading.Tasks;
using System.Configuration;
using System.Windows.Forms;
using System.Threading;
using ProjectName.Properties;
using System.Security.Permissions;
using Microsoft.Win32;
Luke
  • 1,077
  • 13
  • 33
  • 1
    Your project needs to reference `System.Configuration.dll` and you need to have `using System.Configuration` at the top of your code file since you aren't specifying the namespace, – D Stanley Apr 01 '16 at 02:29
  • @DStanley - I have included the System.Configuration using at the top of the code - I edited the question to clarify this. I haven't actually confirmed the .dll is in the references so will double check that now. – Luke Apr 01 '16 at 02:35
  • 1
    In what way is the `user.Config` corrupt? Could it be breaking the project's reference to `system.Configuration`? – D Stanley Apr 01 '16 at 02:35
  • 2
    the _project_ needs to have a reference to `system.Configuration` as well. – D Stanley Apr 01 '16 at 02:36
  • @DStanley - you are correct, I had forgotten to tick system.Configuration in the references part of my project in MVS – Luke Apr 01 '16 at 02:37

0 Answers0