views:

304

answers:

2

I get the message that the namespace can't be found when I use the code below. Where does the AccessDeniedException live?

try { ... } 
catch (SomeKindOfException ex) 
{ 
MessageBox.Show(ex.Message); 
} 
catch (AccessDeniedException ex) 
{ 
//Do something else 
}

Thanks

+1  A: 

I don't think that's the exception you're looking for. The only one with this name (that I can find) is in a Sharepoint namespace. Try attaching the debugger and seeing exactly what the type of the thrown exception is.

The type of the exception is going to vary depending on your context. So for example, if it's an "access denied" when trying to open a file, it could be a FileLoadException, or something similar. If it's encountered because of Code Access Security, it will be SecurityException. And so on.

dpurrington
A: 

You may need to give the full namespace on the exception, or have a using statement at the top of your code file so .NET knows where to find the exception you're talking about. If that doesn't work, maybe you need to add the DLL that contains that exception to the "REFERENCES" list in your project.

rwmnau