473,503 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catch exception in wpf PrincipalPermission(SecurityAction.Demand, Role = "Admin")

1 New Member
I am working on a wpf app on basic authentication set ups with different roles. Say, two rules like Admin and Staff. Admin can add/delete users, but Staff can't. Now If I login as Admin, I can add/delete users who can access the app, but if I login as the role Staff, if I do add/delete users operations, the application will crash. I know the problem is I only allow Admin to perform such actions. But any ideas on how to throw an exception so that the app won't crash. I post my code, any ideas? Thanks in advance.

Expand|Select|Wrap|Line Numbers
  1. [PrincipalPermission(SecurityAction.Demand, Role = "Admin")]
  2. public partial class UserRegistrationView : Window, IView
  3. {
  4.     public UserRegistrationView()
  5.     {
  6.  
  7.         InitializeComponent();
  8.     }
  9.  
  10.     private void btnCancel_Click(object sender, RoutedEventArgs e)
  11.     {
  12.         this.Close();
  13.     }
  14.  
  15.     private void btnUpdate_Click(object sender, RoutedEventArgs e)
  16.     {
  17.         this.Close();
  18.     }
  19.  
  20.     public IViewModel ViewModel
  21.     {
  22.         get
  23.         {
  24.             return DataContext as IViewModel;
  25.         }
  26.         set
  27.         {
  28.             DataContext = value;
  29.         }
  30.     }
  31. }
  32.  
Aug 19 '13 #1
0 1192

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2137
by: Francisco Fagas | last post by:
Hi, you can put your code between: try{ }catch(Exception ex){;} in codebehind and your html code: response.write(ex.Message) the last code is in c#, remember that C# is Key sensitive. ...
5
27366
by: David | last post by:
I am having a bit of a problem with catching an exception within a thread. Here is the scenario: I have a Windows Form. I create a new thread. This new thread calls a method in another DLL...
3
4839
by: Pete Davis | last post by:
I've got the following code: try { reader = new StreamReader(configFile); XmlSerializer serializer = new XmlSerializer(typeof(ServerConfig)); config = (ServerConfig)...
3
3201
by: Sunny | last post by:
Hi, I have created a StringBuilder (Log) in my application that appends all the errors and exceptions in my application. I have included Catch blocks at each sensitive location in my functions. I...
10
5539
by: mttc | last post by:
I read articles that suggest preventing delete by throwing Exception from RowDeleting Event. I not understand where I can catch this Error?
7
6961
by: Mr Flibble | last post by:
Are try { //something } catch { // }
17
3378
by: cashdeskmac | last post by:
Nice and simple one for you all... Is there a time to use Catch(Exception) rather than creating an instance of the Exception, as in Catch(Exception ex)?
7
2480
by: Daimler | last post by:
i am using visual c++ 2005 clr window form with try and catch a serial port readline. the codes are as follows: - try{ Form1::textBox1->Text = Form1::serialPort1->ReadLine();
7
10082
by: suneethadotnet | last post by:
HI, i want to know if there is any exception in finally then how to catch exception in Finally Block.
1
4614
by: bob | last post by:
I have a console application and a timer inside. The timer will throw an Exception while event Elapsed. but i cannot catch this Excepion, How can I catch the Exception?
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.