<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : [CANCELLED] Exception Handling</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : [CANCELLED] Exception Handling</description>
  <pubDate>Thu, 11 Jun 2026 13:40:08 -700</pubDate>
  <lastBuildDate>Mon, 03 Dec 2007 15:47:32 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=565</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>[CANCELLED] Exception Handling :  Originally posted by Bill JensenDo...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2073#2073</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=24" rel="nofollow">Linguinut</a><br /><strong>Subject:</strong> 565<br /><strong>Posted:</strong> 03-Dec-2007 at 3:47pm<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by Bill Jensen</strong></em><br /><br />Do you really want an exception in this case?&nbsp; If the user isn't in Sales, wouldn't you want execution to just continue without New, Delete and Save buttons?</td></tr></table><DIV>&nbsp;</DIV><DIV>This is not my choice when using declarative security attributes.&nbsp; A security exception is thrown when the condition is not met.&nbsp; It needs to be handled.</DIV><DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by Bill Jensen</strong></em><br /><br /></DIV><DIV>You could also use:</DIV><DIV>&nbsp;</DIV><DIV>IPrincipal myPrincipal = Thread.CurrentPrincipal;</DIV><DIV>PageToolBar.AddNewItemEnabled = myPrincipal.IsInRole("Sales");</DIV><DIV>etc.</td></tr></table></DIV><DIV>&nbsp;</DIV><DIV>Certainly.&nbsp; I am just looking for the cleanest, most efficient way of doing this.&nbsp; Is this it?</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by Bill Jensen</strong></em><br /><br />&nbsp;</DIV><DIV>Re your last question,</DIV><DIV>&nbsp;</DIV><DIV>If you're removed&nbsp;disabled the&nbsp;ability to change data, why would there be any changes to prompt for saving in the application save handler?</td></tr></table></DIV><DIV>&nbsp;</DIV><DIV>If all I do to the viewcontrol is remove the ability to click a button based on role, the user would still have the ability to change a combo box, or the string in a text box, or some other data-bound control on the form.&nbsp; I suppose, I could set the form to read-only based on user role.&nbsp; Is that even possible?&nbsp; </DIV><DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by Bill Jensen</strong></em><br /><br /></DIV><DIV>Even if there were some by mistake, you could check the user role in the application close handler and skip both the prompt and the save.</DIV><DIV>&nbsp;</DIV><DIV>Bill J.</DIV></td></tr></table> <DIV>&nbsp;</DIV><DIV>Yup.&nbsp; Sure.&nbsp; Can you imagine the code in that close event, though?&nbsp; After ten business modules and 60-70&nbsp;workitems running around.&nbsp; Whew!&nbsp; Again, I am just trying to determine the best way to do this.</DIV><DIV>&nbsp;</DIV><DIV>For years, I have done the IF INROLE OR USERNAME=?&nbsp;THEN DO SOMETHING route.&nbsp; It is littered all throughout my code.&nbsp; Messy.&nbsp; Really messy.&nbsp; One little change can start a debugging&nbsp;avalanche.&nbsp; The Enterprise Library seems to have an answer for this, but it does not seem like anyone had <EM>really</EM> put this stuff together.&nbsp; Can anyone tell me what the best practice is?&nbsp; Do I stick with the imperative logic in all my code?&nbsp; Is there a clean way to handle the declarative methods and their exceptions?&nbsp; Do I scrap it all and come up with my own scheme?</DIV><DIV>&nbsp;</DIV><DIV>If this is not the proper forum for this question, then please point me in the right direction.&nbsp; Since the business object is directly involved, I was hoping someone familiar with DevForce may have run into this security issue&nbsp;before.</DIV>]]>
   </description>
   <pubDate>Mon, 03 Dec 2007 15:47:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2073#2073</guid>
  </item> 
  <item>
   <title>[CANCELLED] Exception Handling : Do you really want an exception...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2071#2071</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=97" rel="nofollow">Bill Jensen</a><br /><strong>Subject:</strong> 565<br /><strong>Posted:</strong> 03-Dec-2007 at 2:41pm<br /><br />Do you really want an exception in this case?&nbsp; If the user isn't in Sales, wouldn't you want execution to just continue without New, Delete and Save buttons?<DIV>&nbsp;</DIV><DIV>You could also use:</DIV><DIV>&nbsp;</DIV><DIV>IPrincipal myPrincipal = Thread.CurrentPrincipal;</DIV><DIV>PageToolBar.AddNewItemEnabled = myPrincipal.IsInRole("Sales");</DIV><DIV>etc.</DIV><DIV>&nbsp;</DIV><DIV>Re your last question,</DIV><DIV>&nbsp;</DIV><DIV>If you're removed&nbsp;disabled the&nbsp;ability to change data, why would there be any changes to prompt for saving in the application save handler?</DIV><DIV>&nbsp;</DIV><DIV>Even if there were some by mistake, you could check the user role in the application close handler and skip both the prompt and the save.</DIV><DIV>&nbsp;</DIV><DIV>Bill J.</DIV>]]>
   </description>
   <pubDate>Mon, 03 Dec 2007 14:41:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2071#2071</guid>
  </item> 
  <item>
   <title>[CANCELLED] Exception Handling : So, since getting declarative...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2049#2049</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=24" rel="nofollow">Linguinut</a><br /><strong>Subject:</strong> 565<br /><strong>Posted:</strong> 30-Nov-2007 at 4:37pm<br /><br />So, since getting declarative security checks to work in the model is not feasible, then I am doing this in my CustomerPageController:<DIV><FONT color=#0000ff size=2></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2>protected</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>override</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> ConfigureAddNewItemButton()</FONT></DIV><DIV><FONT size=2>{</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>base</FONT>.ConfigureAddNewItemButton();</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; PageToolBar.AddNewItemEnabled = <FONT color=#0000ff>false</FONT>;</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; PageToolBar.DeleteItemEnabled = <FONT color=#0000ff>false</FONT>;</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; PageToolBar.SaveEnabled = <FONT color=#0000ff>false</FONT>;</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; </FONT><FONT color=#0000ff><FONT size=2>try</FONT></FONT></DIV><DIV><FONT size=2><FONT color=#0000ff>&nbsp;&nbsp;&nbsp; </FONT>{</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetButtonAccessibility();</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; }</FONT></DIV><DIV><FONT size=2><FONT color=#0000ff><FONT color=#000000>&nbsp;&nbsp;&nbsp; </FONT>catch</FONT> (System.<FONT color=#2b91af>Exception</FONT> ex)</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; {</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#2b91af>ExceptionPolicy</FONT>.HandleException(ex, <FONT color=#a31515>"default Policy"</FONT>);</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; }</FONT></DIV><DIV><FONT size=2>}</FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT size=2>&#091;<FONT color=#2b91af>PrincipalPermission</FONT>(<FONT color=#2b91af>SecurityAction</FONT>.Demand, Role = <FONT color=#a31515>@"Sales"</FONT>)&#093;</FONT></DIV><DIV><FONT size=2><FONT color=#0000ff>private</FONT> <FONT color=#0000ff>void</FONT> SetButtonAccessibility()</FONT></DIV><DIV><FONT size=2>{</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; PageToolBar.AddNewItemEnabled = <FONT color=#0000ff>true</FONT>;</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; PageToolBar.DeleteItemEnabled = <FONT color=#0000ff>true</FONT>;</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; PageToolBar.SaveEnabled = <FONT color=#0000ff>true</FONT>;</FONT></DIV><DIV><FONT size=2>}</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Perhaps, this is a cleaner way, since the user who is not allowed to alter customer records will not even be able to click these buttons.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>HOWEVER (and there seems to always be one of these!!), if I create logic on the&nbsp;application close event&nbsp;that detects changes to cached entities (like a customer) and asks the user if they want to save changes before leaving...well, I think you can see the dilemma that I now have.&nbsp; Sure, the button functionality was taken away (a good start, for now), but the actual save event was not!&nbsp; That is why I want this declarative security action to happen at the model level.&nbsp; There are too many areas where I have to do the same&nbsp;security coding over and over again.&nbsp; </FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Oh, well.</FONT></DIV>]]>
   </description>
   <pubDate>Fri, 30 Nov 2007 16:37:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2049#2049</guid>
  </item> 
  <item>
   <title>[CANCELLED] Exception Handling : If I place the try-catch outside...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2044#2044</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=24" rel="nofollow">Linguinut</a><br /><strong>Subject:</strong> 565<br /><strong>Posted:</strong> 30-Nov-2007 at 11:29am<br /><br />If I place the try-catch outside of the model, then whereever I add the ability to create a customer, I would need to employ that structure.&nbsp; Not sure if I like that prospect.&nbsp; If it is in the model, then I only need to work out the details one time.&nbsp;&nbsp; However, here's the next problem that is driving me nuts...<DIV>&nbsp;</DIV><DIV>If I put a try-catch block in the model to handle the exceptions on the create method, what do I do with the return value?&nbsp; In my scenario, a CustomerMaster object needs to be returned.&nbsp; I would rather that the code just not run; however, because of the try-catch, an object must be returned.&nbsp; This gets a bit sticky.&nbsp; Do you have any other tips for this approach?</DIV>]]>
   </description>
   <pubDate>Fri, 30 Nov 2007 11:29:41 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2044#2044</guid>
  </item> 
  <item>
   <title>[CANCELLED] Exception Handling : Sorry to take some time to respond....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2042#2042</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=97" rel="nofollow">Bill Jensen</a><br /><strong>Subject:</strong> 565<br /><strong>Posted:</strong> 29-Nov-2007 at 5:37pm<br /><br /><P>Sorry to take some time to respond.&nbsp; The forum has been quiet lately and I've become very busy with other activities.</P><DIV>First, thanks for finding and posting the answer to the earlier question.&nbsp; The only comment I would make (and this is a general .Net practice, not&nbsp;specific to DevForce or Cabana)&nbsp;is that catching of the&nbsp;<strong>Exception</strong>&nbsp;type is generally discouraged (particularly if it&nbsp;might be handled silently) because it can mask other problems in the application (or at least make them very hard to debug).&nbsp; It might be necessary sometimes, but probably not here.</DIV><DIV>&nbsp;</DIV><DIV>So I'd suggest that you catch only the exception(s) thrown by the call that indicate the condition to be handled, letting others bubble up to higher level handlers.</DIV><DIV>&nbsp;</DIV><DIV>Second, the entity constructor is executed (ultimately) by the Create method, so putting the try-catch there is too late.&nbsp; You need to put it around the call to the CustomerMaster.Create() method or some outer method.</DIV><DIV>&nbsp;</DIV><DIV>Finally, yes, we have tried to keep&nbsp;our Cabana Model assembly CAB-free, but there's nothing that says your Model couldn't depend on the Enterprise Library.&nbsp;&nbsp;&nbsp; You might find that the best place for the try-catch is in your code outside of the model.</DIV><DIV>&nbsp;</DIV><DIV>Thanks,</DIV><DIV>Bill J.</DIV>]]>
   </description>
   <pubDate>Thu, 29 Nov 2007 17:37:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2042#2042</guid>
  </item> 
  <item>
   <title>[CANCELLED] Exception Handling : What is the best way to handle...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2040#2040</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=24" rel="nofollow">Linguinut</a><br /><strong>Subject:</strong> 565<br /><strong>Posted:</strong> 29-Nov-2007 at 12:38pm<br /><br />What is the best way to handle an exception within the Model project?&nbsp; Let's say that I want to&nbsp;allow the create method on an object to a specific group, like this: <DIV><FONT color=#2b91af size=2></FONT>&nbsp;</DIV><DIV><FONT color=#2b91af size=2><FONT color=#000000>&#091;</FONT>PrincipalPermission</FONT><FONT size=2>(</FONT><FONT color=#2b91af size=2>SecurityAction</FONT><FONT size=2>.Demand, Role = </FONT><FONT color=#a31515 size=2>"Sales"</FONT><FONT size=2>)&#093;</FONT></DIV><DIV><FONT color=#0000ff size=2>public</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>static</FONT><FONT size=2> </FONT><FONT color=#2b91af size=2>CustomerMaster</FONT><FONT size=2> Create(</FONT><FONT color=#2b91af size=2>PersistenceManager</FONT><FONT size=2> pPersMgr, </FONT><FONT color=#0000ff size=2>string</FONT><FONT size=2> pCustname, </FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> pStatus){...}</DIV></FONT><DIV>&nbsp;</DIV><DIV>How do I handle that?&nbsp; Where would the try-catch block be to handle such an exception?&nbsp; Object constructor?&nbsp; If I do this, wouldn't I need to add the references to the Enterprise Library assemblies into the Model project?&nbsp; Would I then be violating some kind of CAB rule?</DIV><DIV>&nbsp;</DIV><DIV>I know...a lot of questions.</DIV>]]>
   </description>
   <pubDate>Thu, 29 Nov 2007 12:38:30 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2040#2040</guid>
  </item> 
  <item>
   <title>[CANCELLED] Exception Handling : This is actually quite simple...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2039#2039</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=24" rel="nofollow">Linguinut</a><br /><strong>Subject:</strong> 565<br /><strong>Posted:</strong> 29-Nov-2007 at 11:08am<br /><br /><P>This is actually quite simple to resolve.</P><P>In the Exception Handling Application Block and within the "default Policy", I added an entry for&nbsp;SecurityException.&nbsp; I&nbsp;set the PostHandlingAction to "None" but added a logging handler so that an email would be generated and an entry would be made into the local Application event log.</P><DIV>Next, I added a try-catch block in the AddPageLinks method, like this:</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#0000ff size=2>private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> AddPageLinks(</FONT><FONT color=#2b91af size=2>NavViewContext</FONT><FONT size=2> context)</FONT></DIV><DIV><FONT size=2>{</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; </FONT><FONT color=#0000ff><FONT size=2>try</FONT></FONT></DIV><DIV><FONT size=2><FONT color=#0000ff>&nbsp;&nbsp;&nbsp; </FONT>{</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.AddNavTaskLink(<FONT color=#a31515>"Customers"</FONT>, ShowCustomersPageHandler, <FONT color=#2b91af>ResourceNames</FONT>.CustomersImage);</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.AddNavTaskLink(<FONT color=#a31515>"Sales Orders"</FONT>, ShowSalesOrdersPagePageHandler, <FONT color=#2b91af>ResourceNames</FONT>.UserImage);&nbsp;&nbsp;&nbsp; </FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#008000><FONT size=2>// Add NavBar Links Here &lt;&lt;*** Wizard Marker - Do not edit, move o</FONT></FONT><FONT color=#008000><FONT size=2>r delete ***&gt;&gt;</FONT></FONT></FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddPageLinksForMarketing(context);</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; }</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>catch</FONT> (<FONT color=#2b91af>Exception</FONT> ex)</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; {</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>if</FONT> (<FONT color=#2b91af>ExceptionPolicy</FONT>.HandleException(ex, <FONT color=#a31515>"default Policy"</FONT>))</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>throw</FONT>;</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; }</FONT></DIV><DIV><FONT size=2>}</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>What happens now&nbsp;is that the Exception Handling is done at the <EM>module level</EM> rather than the <EM>application level</EM>.&nbsp; If the exception is actually a SecurityException, it will be trapped, logged and an email sent (since no other process occurs, the program continues--user is totally unaware); however, if it is something else, then the catch block throws the exception so that the next level in the application can then handle it.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>This is quite a powerful tool.&nbsp; I am glad that I am beginning to understand it.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Bill</FONT></DIV><span style="font-size:10px"><br /><br />Edited by Linguinut - 29-Nov-2007 at 11:10am</span>]]>
   </description>
   <pubDate>Thu, 29 Nov 2007 11:08:37 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2039#2039</guid>
  </item> 
  <item>
   <title>[CANCELLED] Exception Handling : When I employ the PrincipalPermission...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2032#2032</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=24" rel="nofollow">Linguinut</a><br /><strong>Subject:</strong> 565<br /><strong>Posted:</strong> 28-Nov-2007 at 2:24pm<br /><br /><P>When I employ the PrincipalPermission attribute for a method in a class, and the user is not in the role specified, the application throws an exception.&nbsp; Example code from SalesModuleController.cs file:</P><DIV><FONT color=#0000ff size=2>private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> AddPageLinks(</FONT><FONT color=#2b91af size=2>NavViewContext</FONT><FONT size=2> context)</DIV><DIV>{</DIV><DIV>&nbsp;&nbsp;&nbsp; context.AddNavTaskLink(</FONT><FONT color=#a31515 size=2>"Customers"</FONT><FONT size=2>, ShowCustomersPageHandler, </FONT><FONT color=#2b91af size=2>ResourceNames</FONT><FONT size=2>.CustomersImage);</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; context.AddNavTaskLink(</FONT><FONT color=#a31515 size=2>"Sales Orders"</FONT><FONT size=2>, ShowSalesOrdersPagePageHandler, </FONT><FONT color=#2b91af size=2>ResourceNames</FONT><FONT size=2>.UserImage);</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; AddPageLinksForMarketing(context);</FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT color=#008000 size=2>&nbsp;&nbsp;&nbsp; // Add NavBar Links Here &lt;&lt;*** Wizard Marker - Do not edit, move or delete ***&gt;&gt;</FONT></DIV><DIV><FONT size=2>}</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>&#091;</FONT><FONT color=#2b91af size=2>PrincipalPermission</FONT><FONT size=2>(</FONT><FONT color=#2b91af size=2>SecurityAction</FONT><FONT size=2>.Demand, Role="</FONT><FONT color=#a31515 size=2>Marketing"</FONT><FONT size=2>)&#093;</FONT></DIV><DIV><FONT color=#0000ff size=2>private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> AddPageLinksForMarketing(</FONT><FONT color=#2b91af size=2>NavViewContext</FONT><FONT size=2> context)</FONT></DIV><DIV><FONT size=2>{</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; context.AddNavTaskLink(</FONT><FONT color=#a31515 size=2>"Leads"</FONT><FONT size=2>, ShowLeadMasterPagePageHandler, <FONT color=#2b91af>R</FONT></FONT><FONT color=#2b91af size=2>esourceNames</FONT><FONT size=2>.UserImage);</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; context.AddNavTaskLink(</FONT><FONT color=#a31515 size=2>"Markets"</FONT><FONT size=2>, ShowMarketMasterPagePageHandler, </FONT><FONT color=#2b91af size=2>ResourceNames</FONT><FONT size=2>.SalesOrdersImage);</FONT></DIV><DIV><FONT size=2>}</DIV></FONT><P>Now, what is&nbsp;happening should happen...a SecurityException is thrown because a user does not belong to the Marketing group.&nbsp; The problem is that I am having trouble handling that exception in CAB/DF.&nbsp; The code bombs at this point in the ShellApplication.cs file (marked in <FONT color=#ff0000>red</FONT>):</P><DIV><FONT color=#0000ff size=2>private</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>static</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> HandleException(</FONT><FONT color=#2b91af size=2>Exception</FONT><FONT size=2> ex)</FONT></DIV><DIV><FONT size=2>{</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>if</FONT> (ex == <FONT color=#0000ff>null</FONT>)</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>return</FONT>;</FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; </FONT><FONT color=#008000><FONT size=2>// ToDo: Intercept LoginCancelException and terminate the app</FONT></FONT></DIV><DIV><FONT size=2><FONT color=#008000>&nbsp;&nbsp;&nbsp; </FONT><FONT color=#ff0000>ExceptionPolicy.HandleException(ex, "default Policy");</FONT></FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; </FONT><FONT color=#008000><FONT size=2>// ToDo: Do a better job of unfolding the exception and dump it into the debug log as well.</FONT></FONT></DIV><DIV><FONT size=2><FONT color=#008000>&nbsp;&nbsp;&nbsp; </FONT><FONT color=#2b91af>MessageBox</FONT>.Show(</FONT><FONT size=2><FONT color=#a31515>"An unhandled exception occurred, and the application is terminating. For more information, see your Application event log."</FONT>);</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp; <FONT color=#2b91af>Application</FONT>.Exit();</FONT></DIV><DIV><FONT size=2>}</FONT></DIV><DIV>&nbsp;</DIV><DIV>The initial exception listed is a ModuleLoadException, not a SecurityException, as expected.&nbsp; The SecurityException is baked into the InnerException information.</DIV><DIV>&nbsp;</DIV><DIV>So, how do I properly capture this SecurityException?&nbsp; I have tried several variations in the app.config file, but I cannot seem to get to the right combination.&nbsp; I hope you can provide some direction on this.</DIV><DIV>&nbsp;</DIV><DIV>Bill</DIV><span style="font-size:10px"><br /><br />Edited by Linguinut - 06-Dec-2007 at 4:39pm</span>]]>
   </description>
   <pubDate>Wed, 28 Nov 2007 14:24:15 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=565&amp;PID=2032#2032</guid>
  </item> 
 </channel>
</rss>