Click here to Skip to main content
14,331,020 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am getting "Exception is the namespace but used as a type" Error

public static void logger(Exception exception)
{
StringBuilder sbExceptionMessage = new StringBuilder();
}

How to resolve this?

this is the .cs file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Diagnostics;
using System.Text;

namespace Exception
{
    public class Class1
    {
        public static void logger(Exception ex) //getting error here
        {


        }
    }
}
Posted
Updated 5-Jun-13 22:15pm
v3
Comments
lukeer 6-Jun-13 4:11am
   
Show some more of the surrounding code:
In what class does this code reside?
In what namespace is thiat class?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You have declared Exception to be a namespace in your project.
Now when you try and use it in your exception handler i.e. (Exception ex), you will run into a problem. This is assumed to be a namespace by the compiler.

Try this instead -
namespace Exception
{
    public class Class1
    {
        public static void logger(System.Exception ex) //getting error here
        {


        }
    }
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100