Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am getting "Exception is the namespace but used as a type" Error

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

How to resolve this?

this is the .cs file.

C#
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

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 -
C#
namespace Exception
{
    public class Class1
    {
        public static void logger(System.Exception ex) //getting error here
        {


        }
    }
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900