exception

Why are try-catch in main() bad?

不问归期 提交于 2020-01-01 08:06:27
问题 Could someone explain to me why it is considered inapropriate to have a try-catch in the main() method to catch any unhandled exceptions? [STAThread] static void Main() { try { Application.Run(new Form1()); } catch (Exception e) { MessageBox.Show("General error: " + e.ToString()); } } I have the understanding that this is bad practice, but not sure why. 回答1: I don't think its necessarily bad practice. There are a few caveats however... I believe the point of whoever called this "bad practice"

how to print an exception using logger?

十年热恋 提交于 2020-01-01 07:33:28
问题 I have a situation in which I want to print all the exception caught in catch block using logger. try { File file = new File("C:\\className").mkdir(); fh = new FileHandler("C:\\className\\className.log"); logger.addHandler(fh); logger.setUseParentHandlers(false); SimpleFormatter formatter = new SimpleFormatter(); fh.setFormatter(formatter); } catch (Exception e) { logger.info(e); } i got the error logger cannot be applied to java.io.Exception... My concern is if I do so many thing in try

Drop event when select OK to restart Launcher when ANR occurs

↘锁芯ラ 提交于 2020-01-01 07:11:10
问题 When ANR occurs for Launcher,dialog pops up and the Launcher resume then. Select OK to restart Launcher after the launcher resume to respond, the rest keys will be dropped. The problem occurs in my developing environment and it's hard to reproduce.So I do a test for this: Create a simple APK as Launcher, and sleep some time in onCreat or onResume to let the ANR occurs Start the Launcher and press key to let ANR occurs after sleep the view is normally shown behind the ANR dialog select OK to

“EXC_BAD_ACCESS: Unable to restore previously selected frame” Error, Array size?

こ雲淡風輕ζ 提交于 2020-01-01 05:43:05
问题 I have an algorithm for creating the sieve of Eratosthenes and pulling primes from it. It lets you enter a max value for the sieve and the algorithm gives you the primes below that value and stores these in a c-style array. Problem: Everything works fine with values up to 500.000, however when I enter a large value -while running- it gives me the following error message in xcode: Program received signal: “EXC_BAD_ACCESS”. warning: Unable to restore previously selected frame. Data Formatters

Thymeleaf: How to use boolean operator in JavaScript using Thymeleaf

泪湿孤枕 提交于 2020-01-01 05:39:07
问题 I am using thymeleaf, in javascript using th:inline="javascript" , but when we add Boolean conditions in java script thymeleaf thow an exception as below: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 22; The entity name must immediately follow the '&' in the entity reference. com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper

Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

十年热恋 提交于 2020-01-01 05:36:34
问题 I have integrated my project with another one (MVC3 application). Then I'm getting below error. Both the projects are working fine with the Microsoft Enterprise Library version 5.2.414.0 . After integrating only some of the pages are working and remaining pages throwing below exception. Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file

Wpf- Unable to cast MenuItem to Listbox?

旧城冷巷雨未停 提交于 2020-01-01 05:35:10
问题 I am getting a very strange exception. I get the exception: "'Set connectionId threw an exception.' Line number '26' and line position '34'." When I look at the Inner Exception I get: "Unable to cast object of type 'System.Windows.Controls.MenuItem' to type 'System.Windows.Controls.ListBox'." I have narrowed the cause of the exception to the MenuItem in the TreeViewItem style contained in this TreeView : <TreeView x:Name="ProjectElementTreeView" ItemsSource="{Binding ProjectElementCollection}

Catching a custom Exception thrown by a WebMethod on ASP.NET WebService

巧了我就是萌 提交于 2020-01-01 05:13:06
问题 I have a classical asp.net web service (asmx) and a web method in it. I need to throw a custom exception for some case in my web method, and I need to catch that specific custom exception where I call the web service method. [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { [WebMethod] public HelloWorldOutput HelloWorld(HelloWorldInput input) { try { // My Code return new

How to treat unhandled thread-exceptions in ASP.NET?

坚强是说给别人听的谎言 提交于 2020-01-01 05:06:44
问题 How is an ASP.NET application supposed to deal with unhandled exceptions which are occuring on a non-request background thread (due to bugs)? By default, such exceptions cause the process to terminate. This is unacceptable in the setting of an ASP.NET worker process because concurrently running requests are aborted unpredictably. It is also a performance problem. Exceptions on a request thread are not a problem because ASP.NET handles them (by showing an error page). The AppDomain

How to treat unhandled thread-exceptions in ASP.NET?

白昼怎懂夜的黑 提交于 2020-01-01 05:06:13
问题 How is an ASP.NET application supposed to deal with unhandled exceptions which are occuring on a non-request background thread (due to bugs)? By default, such exceptions cause the process to terminate. This is unacceptable in the setting of an ASP.NET worker process because concurrently running requests are aborted unpredictably. It is also a performance problem. Exceptions on a request thread are not a problem because ASP.NET handles them (by showing an error page). The AppDomain