How do I gracefully handle XamlParseExceptions?
If a control that is dynamically loaded as part of a template has an error, it causes a XamlParseException which crashes the entire application.
I can hook into the Application.DispatcherUnhandledException event, but setting Handled to true on the DispatcherUnhandledExceptionEventArgs argument does not disable the problematic control. As a result, WPF tries again to apply the template, causing the
error to be thrown once more, resulting in an infinite loop.
Is there any way to disable the problematic control so that it stops trying to render?
Here is how to reproduce this scenario:
1. Create a WPF application.
2. Add a Window called "Dialog1" and a UserControl called "UserControl1".
3. Add the following code to each file (namespaces and root XAML elements left out):
App.xaml.cs:
(Also add the following namespace reference to the top: using System.Windows.Threading;)
public partial class App : Application
protected override void OnStartup(StartupEventArgs e)
base.OnStartup(e);
DispatcherUnhandledException += OnDispatcherUnhandledException;
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
e.Handled = true;
Dialog1.xaml:
(Also add the following namespace reference: xmlns:local="clr-namespace:your app namespace")
<StackPanel>
<Button Content="Cause XamlParseException" Click="Button_Click" />
<ListBox ItemsSource="{Binding Mode=OneWay}">
<ListBox.ItemTemplate>
<DataTemplate>
<local:UserControl1 />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
Dialog1.xaml.cs:
public partial class Dialog1 : Window
public Dialog1()
InitializeComponent();
private void Button_Click(object sender, RoutedEventArgs e)
var list = new object[1];
list[0] = new object();
DataContext = list;
MainWindow.xaml:
<StackPanel>
<Button Content="Show Dialog" Click="Button_Click" />
</StackPanel>
MainWindow.xaml.cs:
public partial class MainWindow : Window
public MainWindow()
InitializeComponent();
private void Button_Click(object sender, RoutedEventArgs e)
var dlg = new Dialog1();
dlg.ShowDialog();
UserControl1.xaml.cs:
public partial class UserControl1 : UserControl
public UserControl1()
InitializeComponent();
throw new Exception();
Run the solution, click the "Show Dialog" button, and then click the "Cause XamlParseException" button. This will cause the exception to be thrown repeatedly.
>>Is there any way to disable the problematic control so that it stops trying to render?
Not apart from catching and handling the exception in your code where it is being raised:
public UserControl1()
InitializeComponent();
try
throw new Exception();
catch (Exception ex)
There are some exceptions that you can't recover from and setting the Handled property to true in this case just causes the same exception to ge thrown over and over again.
The most meaningful thing you can do when an DispatcherUnhandledException occurs is to log the exception and then terminate the application:
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
Exception ex = e.Exception;
//log the exception...
Environment.Exit(1);
Setting the Handled property of the DispatcherUnhandledExceptionEventArgs to true and trying to continue on like nothing ever happened may leave your application in an undefined state and is rarely a good idea.
Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.
Similar Messages
-
How to generate the handling unit in alphanumeric by sequence
Is there any way to serial generate the box id in alphanumeric?
such as number range set is from 00000 ~ ZZZZZ
when the number is 00009, the next number can be auto got as 0000A,
can SAP support this function?Could you please point me in the right direction of how to set up handling unit ranges with alphanumeric characters?
Thanks -
How to Call Event Handler Method in Another view
Hi Experts,
Can anybody tell me how to call Event handler Method which is declared in View A ,it Should be Called in
view B,Thanks in Advance.
Thanks & Regards
Santhoshhi,
1) You can make the method EH_ONSELECT as public and static and call this method in viewGS_CM/ADDDOC using syntax
impl class name of view GS_CM/DOCTREE=>EH_ONSELECT "method name.
or
2)The view GS_CM/ADDDOC which contains EH_ONSELECT method has been already enhanced, so I can't execute such kind of operation one more time.
or
3)If both views or viewarea containing that view are under same window , then you can get the instance ofGS_CM/DOCTREE from view GS_CM/ADDDOC through the main window controller.
lr_window = me->view_manager->get_window_controller( ).
lv_viewname = 'GS_CM/DOCTREE '.
lr_viewctrl ?= lr_window ->get_subcontroller_by_viewname( lv_viewname ).
Now you can access the method of view GS_CM/DOCTREE .
Let me know in case you face any issues.
Message was edited by: Laure Cetin
Please do not ask for points, this is against the Rules of Engagement: http://scn.sap.com/docs/DOC-18590 -
ADF: Gracefully handling JDBC connection errors? Part II
Hi gang
I while back I posted a forum post to find a solution to "display a specific web page when the JDBC connection drops out on our ADF application, specifically the following error: oracle.jbo.DMLException: JBO-26061: Error while opening JDBC connection"
...you can see the original post here:
Re: ADF: Gracefully handling JDBC connection errors?
For the life of me I can't get this to work now. It appears I can't redirect to another page during the call to reportException. I've had a play with different methods of redirecting, as seen in the following code sample:
public class ErrorHandlerImpl extends DCErrorHandlerImpl {
public ErrorHandlerImpl() {
super(true);
@Override
public void reportException(DCBindingContainer dCBindingContainer, Exception exception) {
// try {
String message = exception.getMessage();
if (message.indexOf("JBO-26061") >= 0) {
// Method 1
FacesContext fc = FacesContext.getCurrentInstance();
UIViewRoot viewRoot =
fc.getApplication().getViewHandler().createView(fc, "faces/errorPage.jspx");
fc.setViewRoot(viewRoot);
fc.renderResponse();
// Method 2
// FacesContext fc = FacesContext.getCurrentInstance();
// fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "goError");
// fc.responseComplete();
// Method 3 - required IOExcepition handler
// FacesContext.getCurrentInstance().getExternalContext().redirect("faces/errorPage.jspx");
} else
super.reportException(dCBindingContainer, exception);
// } catch (IOException e) {
}... with no success.
Has anyobody any other solutions or advice on getting this to work?
Your help appreciated.
Thanks & regads,
CM.
PS. JDev 11gR1 ADF BC + ADF Faces RCHi Frank
Yep, I' tried redirect, that was method 3 (you can see all 3 methods I've attempted, last 2 are commented out).
With the declarative ADFc exception handler, problem is it's a catch all, not specifically for JBO-26061. Can you think of a way I can tailor fit it for JBO-26061 with a custom message "Database down"?
In addition the exception handler is not consistently called. As example, if you're moving between pages rather than operating on 1 page, the standard af:messages error dialog is shown if the db connection has been dropped, rather than navigating to the exception handler page. As such it seems the DCErrorHandlerImpl.reportExceptions is the better chokepoint to work from.
Cheers,
CM. -
Business vs. Private purchase - how are App updates handled?
Hi,
I have my own business, but already purchased a few apps for private use on my Mac. Now I need to make a business purchase and I'm wondering how the App Store handles this.
If I switch accounts, can I still see, run, and update the same apps? Do I need to switch accounts to use an app? Do I (please no) need to log out and in to use an app from a different account?
Any help is appreciated, thanks!
VincentYou don't need to be logged in with the purchasing account in order to use a app.
You would have to log in with the purchasing account in order to update.
Matt -
How InDesign comes to know about any changes on document, but not saved. As it shows * on the name of document when it is opened and any changes.
And after saving * symbol is get removed from the name of document. How and where indesign@ handles this?Are you just asking because you want to know, or do you have a problem you need to solve? I don't know how to write a program, but I think what your are describing is not an unusual thing for a program to do. The * tells you that changes have been made since the last save, and the program reserves a portion of memory for undo functions. I suppose a coder could tell you how it works, but I don't think it would help an average user to know, but that's just my opinion.
-
How are session timeouts handled
Hi,
Can anyone tell me how session timeouts are handled by the Servlet
Engine.
What is the exact role of the SessionInvalidator class. Are sessions
correctly timed
out by iAS, because I get strange behaviour in handling session timeouts
in my application
which is following MVC architecture.
What I am observing is that sessions dont seem to timeout after the
length of
time specified and sometimes they do timeout correctly. The difference
between the
time the session should have timed out and when it actually does is too
high, which is
really a concern for us.
Thanks in advance to evryone.
Amar bhat.Hi AmarBhat,
Actually this is a bug in iAS (bug id: 556909, Status: Fixed ). This is
happeninig because iAS has a bad ( late) cleanup of timed out sessions. The
getSession method (HttpSession) calls IsRequestedSessionIdValid() as a check
for timeout and this check returns "Valid" even after a couple of seconds of
timeout. Thus, the getSession from Java layer returns the valid session. So
you are still able to read and write data on the session.
We can specify iAS the session to invalidate itself after being timeout.
Alternately, we can do it manually with HttpSession method, invalidate().
Plese get back if you have any issues.
Thanks,
Rakesh.
Developer -support, iAS.
amar bhat wrote:
Hi,
Can anyone tell me how session timeouts are handled by the Servlet
Engine.
What is the exact role of the SessionInvalidator class. Are sessions
correctly timed
out by iAS, because I get strange behaviour in handling session timeouts
in my application
which is following MVC architecture.
What I am observing is that sessions dont seem to timeout after the
length of
time specified and sometimes they do timeout correctly. The difference
between the
time the session should have timed out and when it actually does is too
high, which is
really a concern for us.
Thanks in advance to evryone.
Amar bhat. -
How does Time Machine Handle separate Boot and User Volumes?
I recently installed an SSD and set it up as my boot drive, and I'm using another hard drive for my Home folder, if I ever run into a scenario that I need to restore my entire system, how will Time Machine handle it?
Will it restore my system back to the drives that they came off of?, in other words will my Boot volume be restored back to the SSD and my Home folder back to the hard drive, or will it restore everything back on the one disk it asks me to select before I click restore?Michael Hoover wrote:
Ok, so if I tried to access a backup from booting with the Snow Leopard install disk I won't be able to select which volume I need to restore?
You would restore the OSX volume via the procedure in #14 of [Time Machine - Frequently Asked Questions|http://web.me.com/pondini/Time_Machine/FAQ.html] (or use the link in *User Tips* at the top of this forum).
You would restore the data-only volume separately, via the "Star Wars" display, per #15 in the FAQ.
I guess I would be better off doing incremental backups with Carbon Copy Cloner on 2 partitions on the same volume.
That would also take two separate operations to restore. (It would be a good idea to do such backups +*in addition+* to Time Machine backups, in case there's a problem with either disk drive or backup app, or a user error like erasing the wrong disk.)
Your scenario is actually quite unlikely; you'd rarely need to restore both volumes at once. If the SSD fails, you'd only need to restore it; if the HD fails, you'd only need to restore that.
It would get a bit more complicated if you get a new Mac, especially one with a single volume. That's one of the reasons it's a good idea to keep at least a minimal Admin account on the OSX volume. -
How will the system handle delta in the below scenario
How will the system handle delta in the below scenario
Day 1
DS--->DSO
PSA
Document Number| Customer | sales value
1001| RAMLAL | 10000
Your change log for DSO will read
Req1| 1001|RAMLAL|10000|N
DSO(overwrite)
1001|RAMLAL|10000|
Day 1
DSO--->Cube
Req1| 1001|RAMLAL|10000|
Day2
DS--->DSO
PSA
Document Number| Customer | sales value
1001| RAMLAL | 30000
Your change log for DSO will read
Req2 | 1001 | RAMLAL | -10000 | X
Req2 | 1001 | RAMLAL | 30000
DSO(Overwrite)
1001 | RAMLAL | 30000
Day 2
DSO--->Cube
Req1|1001|RAMLAL|10000|
Req2|1001|RAMLAL|20000|
Please explain with example
Scenario 1: Req1 & Req2 are deleted ONLY from change log on Day 3
On Day 4:
DS--->DSO
Document Number| Customer | sales value|STOR_NO(ROCANCEL)
1001| RAMLAL | 10000|C
What will happen to the Sales Value in the cube?
What will happen to the Req1&Req2 in the cube?
Thanks
TanyaTanya,
Please explain with example
Scenario 1: Req1 & Req2 are deleted ONLY from change log on Day 3
On Day 4:
DS--->DSO
Document Number| Customer | sales value|STOR_NO(ROCANCEL)
1001| RAMLAL | 10000|C
What will happen to the Sales Value in the cube?
What will happen to the Req1&Req2 in the cube?
Document Number| Customer | sales value|STOR_NO(ROCANCEL)
1001| RAMLAL | 10000 |C
--> Here 1000 is not correct value, as 1000 is change to 3000. It should be 3000. record should be as below.
Document Number| Customer | sales value|STOR_NO(ROCANCEL)
1001| RAMLAL | 30000 |C
--> As this data related to sales, and i hope you are using standard ABR extractors(Business Content).
ABR datasources delivers before and after images.
Before image:
Document Number| Customer | sales value|STOR_NO(ROCANCEL)
1001| RAMLAL | -3000 |C
Before image:
Document Number| Customer | sales value|STOR_NO(ROCANCEL)
1001| RAMLAL | 0 |C --> value changed from 3000 to Zero.
If you are loading in additive or Overwrite into an ODS total sales for 1001 at end of day 4 will be Zero.
Hope it helps
Srini -
How does Media Manager handle Motion Projects within the Sequence being cop
How does Media Manager handle Motion Projects within the Sequence being copied?
I've highlighted my sequence, opened Media Manager, and copied it to another drive. When I open up the sequence in it's new project, the rendered Motion Project plays within my sequence but it won't let me go back into this Motion Project to make changes. I tried starting over. This time I highlighted the actual motion sequence and clip that is created within FCP after sending something to Motion and copied those to the new drive. When I went into the newly created 'media' folder and double clicked on the motion project it launched. It looked liked it was going to play but while my crops moves and borders were there, the filmed material is shown as a freeze frame for the duration of the motion project.
I did this with and without 'including master clips within selection'. Any advice would be appreciated. Thanks.Is there anyone who knows the answer to this? Thanks.
-
How to create an handle for Miniport driver Ioctl interface?
Hi All,
I am trying to create an handle for my miniport driver Ioctl interface, but it showing the following error while opening the handle with CreateFile API.
"you are requesting IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMTYPE,
which has been deprecated. Use IOCTL_HAL_GET_DEVICE_INFO::SPI_GETPLATFORMNAME
instead"
Can anyone suggest on how to create the handle for Miniport Ioctl interface?
Thank you,
SagarHi,
I have seen this error only in GUI based apps. Maybe you are pointing to the wrong error.
Check if CreateFile returns INVALID_HANDLE_VALUE. API return value should give you more information.
Regards,
Balaji. -
How does the iMac handle HD video editing?
Tired of Window PCs, looking to buy an Apple System. I would like to do some video editing but want to make sure I get a powerful enough system from the start. How does the iMac handle HD video editing or should I look a better, faster computer?
I have a mid 2011 iMac, 21 inch 4 GB RAM (the next to bottom iMac), Lion. I run Final Cut Express 4 with no difficulty (at least so far). It is certainly fast enough. My old G5, 7 years old, was also, and the iMac is faster.
As I remember, I heard from someone on the Final Cut Express Discussions that some people might be having difficulty with FCE 4 on Lion, but I am a bit hazy. Its bigger brother, Final Cut Pro, is also available. I suggest that you post on the Final Cut Express or Final Cut Pro Discussion sites. They have many reliable users. -
How does GRC CUP handle scheduled termination set up in SAP HR ?
Dear Experts,
We are planning to use "HR Tiggers" for Hire, Terminate and transfer events in GRC CUP ? Can some body help me understand how does GRC CUP handle the termination requests that are scheduled in future ?
Thanks
KumarI configured HR trigger rule for infotype 0000 & subtype Z1,field MASSN with value equal to 01 to trigger new hire...i don't see any data being populated into table /VIRSA/INT_TRIG & ?VIRSA/DATA.
I could see the rule in table /VIRSA/RULEATTR.
Any help would be appreciated.
Thanks,
Srinu -
How to get a handle of tcUtilityFactory within Java Task
Hi
I am trying to user op interface within a java task and want to avoid the GUI based coding in adapter factory
I am having doubt about how to get a handle of tcUtilityFactory
the standalone example of getting the handle works fine within a Java task
// ConfigurationClient.ComplexSetting config = ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
// final Hashtable env = config.getAllSettings();
// ioUtilityFactory = new tcUtilityFactory(env, "xelsysadm", "welcome1");
but I want the handle to be provided by adapter runtime env
there is a function call within generated adapter code
APITaskLocal.getUtilityFactory(getDataBase());
but I get null pointer if I try to use it within custom code
has anyone played around with APITaskLocal.getUtilityFactoryHi,
Use this code.
public void init(tcDataProvider dataProvider) {
try {
usrOps = (tcUserOperationsIntf)tcUtilityFactory.getUtility(dataProvider, "Thor.API.Operations.tcUserOperationsIntf");
} catch(Exception e) {
log.error("Unable to initialize: "+e);
You can pass dataProvider in adapter mapping . Map it to Adapter reference->Database reference.
Hope this will help.
Regards
Nitesh -
How to access the handle of the Frame window ?
How to access the handle of the frame window through out the application ?. I want to display an alert box, while I click the fifth inner child component of the Frame . I am using Dialog Class for the alert box, I have to pass the frame handle to the Dialog constructer, I am getting the handle of the frame by getParent().getParent()......getParent().. But can any one suggest any better solution.
If you application extends Frame or JFrame, you could simply refer to "this", or if you create a global or final Frame object that you use as your "top-level" component, you could refer to it this way. Additionally, if you're ever in a situation where you really need to go all the way to the top through n levels of components, I believe you could always do something like this...
// assume myContainer is the "child" component that you're on, and you want to find its top-level parent
Container c = myContainer;
while (c.getParent() != null) {
c = c.getParent();
}
Maybe you are looking for
-
Help with OSX server mail setup
Please if anyone can tell me what I am doing wrong, I would be very grateful. I have a company with an externaly hosted website and an an internally hosted email (OSX server). I have everything kind of working, but some things don't seem quite righ
-
Unable to access Apps on HP Officejet Pro 8600 Plus
Hi guys, I can print wirelessly and print remotely using the ePrint apps on my iphone and ipad. Until recently, I have been able to access the apps, but this has stopped. I now get the following error message: "The printer was unable to connect to
-
Sharing Photostreams in iPhoto 9.4 not working
iPhoto used to be so simple. Now, with Albums, Events, Photos, Journals, Photostreams etc it's all becoming a bit of a dog's breakfast. All I want to do is to share some photos with my family. So I use the new Photostream sharing facility in iPhoto 9
-
Hello, I'm trying to export a CLOB field to a txt file. It's a xml string in the CLOB. I have used different methods but the only which i can use is PUT, PUT_LINE. But: - PUT does only export the 32565 characters. I see that the output of l_pos is 42
-
RMAN ALert Log Message: ALTER SYSTEM ARCHIVE LOG
Created a new Database on Oracle 10.2.0.4 and now seeing "ALTER SYSTEM ARCHIVE LOG" in the Alert Log only when the online RMAN backup runs: Wed Aug 26 21:52:03 2009 ALTER SYSTEM ARCHIVE LOG Wed Aug 26 21:52:03 2009 Thread 1 advanced to log sequence 3