flex write runtime errors stacktrace to file - apache-flex

I am developing a Flex + AIR application. While debugging using Flash Builder sometimes I get runtime errors dialog with 'continue' & 'dismiss all' buttons. But when I release a build(.air) & run the application after installing. Then I don't get the same dialog in the release build.
I need to track these types of runtime errors for that I am trying to write them to a file as logs.
I tried using try catch & writing to file in catch block, but I am not able to get any wayout for unhandled exceptions or runtime errors.
Is there any way to achieve it?
Thanks in advance.

The error dialog is displayed only if you use the debugger version of Flash Player.
You could register an UncaughtErrorEvent handler and log the errors with trace or with the logging API:
private function onApplicationComplete():void
{
loaderInfo.uncaughtErrorEvents.addEventListener(
UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtError);
}
private function onUncaughtError(event:UncaughtErrorEvent):void
{
trace(error);
}

You can't debug compiled AIR application with the Flash debug player because the debug information is removed when you make a release build. You can use something like De MonsterDebugger to output error information, but generally it's a bad idea to show error info in a release build. You should be testing prior to releasing.

In Flash 11.5+ it is now possible to get the stack trace at runtime using error.getStackTrace() see http://renaun.com/blog/2012/09/getting-the-stack-trace-in-a-release-flash-player/
It is working for me in an Air application.

Related

Uno Random Compile Errors

I have created a brand new Uno project and off the bat I get compile errors. I most common one I am getting is a cs 1061 App does not contain a definition for InitializeComponent. The app would run with this error, but once I start adding more pages to the application, the application no longer compiles. How do I resolve this issue? Also, I get this same error for each page that I add. The oddest part about this issue is that the app.xaml.cs suffers from it too.
I am also getting a XLS0411 that is complaining about the background brush that comes with the default page.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
The message about InitializeComponent() is a false positive from Visual Studio, this is a known issue. The Uno Platform documentation recommends to build the project once, close the solution, and then reopen it to get rid of this error.
In general the Error window is less useful with Uno Platform projects because of the various false positives, it's more reliable to check the Build pane in the Output window. The Error window is Intellisense's best guess as what errors your code may have; the Build output is what actually happened when it tried to compile. If you search for "error " from the top of the Build output you should quickly find the reason the compilation failed; this will tell you why it's failing when you add pages to the application.

Error coming up when trying to open up file browser

Currently on my website i am trying to get it so that a user can upload an image from their local images. I have followed a tutorial, but when i debug it and try to open up my images folder i get this error message:
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process."
Please can someone help me here, i have read a few posts; but seen as this is my first time doing this; i dont really understand them.
Thanks for any response!
You are trying to use Windows Forms functionality in a ASP.NET Web Page. Line 140:
FileDialog fldlg = new OpenFileDialog();
Windows Forms is desktop technology. You can't mix that with a ASP.NET web app. You can use the FileUploadControl to enable file uploads in your web application:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx

AIR - Different behaviour when the app is installed and when it runs inside the builder

we are developing an Adobe AIR app using Flex4. We are facing lot of bugs that didn't show up when we run the application inside Flash Builder (both debug mode and run mode), but when we install the app and run it, the app shows a different behaviour. Any idea ? what does it change between running the installed application in the builder and outside ?
Thanks a lot
Ok i've founded the problem using MonsterDebugger in the application running stand alone. The problem was the File.browseForDirectory(). I'm creating the File object, registering the event listener and then calling File.browseForDirectory() and that generate an exception. I switched the order, First creating a new file, then calling File.browseForDirectory() and at last register an event handler and works great.
My guess is that inside the debugger version and inside Flash Builder it takes just few more millisec and the File object is ready when i register the eventlistener but in the stand alone application AS3 code for event listener registration is executed before the File object initialization.

How to solve "NullPointerException" with "Server.processing" error while we are using Flex Builder 3 and BlazeDS?

I am using Flex builder 3, BlazeDS, and Java with Spring and Hibernate framework. I using the remote object to load a string from spring's configuration files. But in testing, I found this fault event like this:
RPC Fault
faultString="java.lang.NullPointerException"
faultCode="Server.Processing"
faultDetail="null"
I have checked the configuration in remote-config.xml and services-config.xml. But it looks good. Some people have talked about this problem around the Internet and I think you can help me and them.
I am using these environment:
Flex Builder 3
BlazeDS 3.2.0
JBoss server
Full stacktrace:
[RPC Fault faultString="java.lang.NullPointerException" faultCode="Server.Processing" faultDetail="null"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:220]
at mx.rpc::Responder/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:53]
at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
at NetConnectionMessageResponder/statusHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:569]
at mx.messaging::MessageResponder/status()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:222]
The java.lang.NullPointerException indicates an error being thrown on the server. To debug this, active debug logging on BlazeDS in the services-config.xml file. You should see detailed debug information in the server console.
When using the BlazeDS/Spring integration take care that you will need to use a custom exception translator in order to obtain meaningful exceptions. Please read this document http://static.springsource.org/spring-flex/docs/1.0.x/reference/html/ch02s08.html
In your case the error is not related to some configuration problems, it seems that is thrown inside your java method. Use a debugger in order to diagnose properly.

Exception that goes away with Clean/Rebuild. How to diagnose/prevent?

Pre-Problem: our office was hit by a worm due to a corporate patching oversight, and the boys in the lab repaved my machine. I needed to re-install all my development tools (Visual Studio 2005, SP1, and the Web Application Project Setup patch) again. The following problem did not occur before this event.
I've been working on an ASP.NET web application project for several months now. I've been editing, debugging, etc without a problem. Then, I added a single line of code, ran it in Debug and got this error:
System.Web.HttpUnhandledException:
Exception of type 'System.Web.HttpUnhandledException'
was thrown.
System.IO.FileLoadException: The given assembly name
or codebase was invalid. (Exception from HRESULT: 0x80131047)
I uncommented the new code, built the project and ran in debug again, but got the same error.
New Code:
Me.frm.btnSubmitChanges.Attributes.Add("onclick", "javascript:return validateSubmit();")
The only way I've been able to fix this is to Clean, then Rebuild the project. I haven't been able to trap where it's happening using breakpoints.
It's happened a couple times in the last few days. What should I be looking at to fix this?
Thank you!
Have you tried to enable Fusion Logger to see if it's an assembly that is failing to load? In C# you can tell the debugger to break at any exception (There's a command you can add by customizing the tool bar called Exceptions). I'm not sure if VB has this but I would assume they do. Can you tell it break on FileLoadException and that might help you understand what's going on.
The line of code you added is pretty innocuous. When you add the code it breaks, have you then done a clean build with that line of code still in and does it work or not?
I did run the Fusion Logger, but did not get any results when the exception occurred. I tried all 4 settings.
The new line of code runs fine after a clean/rebuild.
I haven't used the break on all exceptions before; I'll see if I can find it.

Resources