exception-handling

Is there something known as Array type mismatch exception in C#?

大城市里の小女人 提交于 2019-12-11 02:07:51
问题 My teacher has asked me to write a program in C# to handle "Array type mismatch exception". But i couldn't find anything in the net related to that. I just want to confirm if there exists something like that. 回答1: ArrayTypeMismatchException on MSDN 回答2: Let’s say Class2 derives from Class1, because C# language is covariant when it comes to assigning arrays following assignment is perfectly valid Class1[] generalizedArray; Class2[] specializedArray = new Class2[]{new Class2(),new Class2()};

Program does not contain a static 'main' method suitable for entry point

妖精的绣舞 提交于 2019-12-11 01:51:20
问题 I know that this question has been asked a lot, but none of the solutions seem to work for me. That or I am just incompetent and need to have my hand held through this problem (most likely solution). I looked through all of the classes, and all the build actions are set to compile, so I have no idea what could have gone wrong. Any help? Additional Details: I have been coding the starting of a game, and everything was going good until I got this error: Program does not contain a static 'Main'

Can't determine what is throwing a NullPointer exception

北城以北 提交于 2019-12-11 01:45:21
问题 I have a method that looks like this: try { doStuff(); } catch (Exception ex) { logger.error(ex); } (I don't really use method names like doStuff - this is just to make things easy) In doStuff I do a variety of things, among them is call a data access method (so, another method within doStuff) that ends with the following: } catch (SQLException ex) { logger.error(ex); } finally { try { connection.close(); proc.close(); results.close(); } catch (Exception e) { logger.error(e); } //<--Exception

Is the lifetime of an exception affected by other exceptions?

前提是你 提交于 2019-12-11 01:37:10
问题 As a follow-up to my previous question: If I change the code as follows: struct ExceptionBase : virtual std::exception{}; struct SomeSpecificError : virtual ExceptionBase{}; struct SomeOtherError : virtual ExceptionBase{}; void MightThrow(); void HandleException(); void ReportError(); int main() { try { MightThrow(); } catch( ... ) { HandleException(); } } void MightThrow() { throw SomeSpecificError(); } void HandleException() { try { throw; } catch( ExceptionBase const & ) { // common error

Java Runtime Exception

守給你的承諾、 提交于 2019-12-11 01:26:35
问题 when i run my application i get the following error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:546) at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:460) at javax.swing.text.FlowView.layout(FlowView.java:184) at javax.swing.text.BoxView.setSize(BoxView.java:380) at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349) at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331) at

Why do we need a function try block?

南楼画角 提交于 2019-12-11 01:16:59
问题 This is a follow-up question of the post. Please see the end of this question for a definition of "function try block". Question: If a function try block does not "handle" the exception raised in the constructor, why do we need them after all? Could you give an example taking advantage of function try block? Considering the following code. #include <iostream> #include <new> #include <exception> using namespace std; struct X { int *p; X() try : p(new int[10000000000]) {} catch (bad_alloc &e) {

How do I return a value from a PureScript function with an EXCEPTION effect?

风流意气都作罢 提交于 2019-12-11 01:05:28
问题 I've just started learning about PureScript effects, and I'm stuck trying to make a function that has an EXCEPTION effect. lengthGt5 :: forall eff. String -> Eff (err :: EXCEPTION | eff) String lengthGt5 a = if (length a <= 5) then throwException $ error "Word is not the right length!" else a main = do word <- catchException handleShortWord (lengthGt5 "test") log word where handleShortWord err = do log (message err) return "Defaut::casserole" When I try and run this I get the following error

Reusing try catch for wcf call

折月煮酒 提交于 2019-12-11 00:54:56
问题 I have a series of methods that call wcf services and all of them have the same try catch code Response Method1(Request request) { Response response = null; using(ChannelFactory<IService1> factory = new ChannelFactory<IService1>(myEndpoint)) { IService1 channel = factory.CreateChannel(); try { response = channel.Operation(request); } catch(CommunicationException ex) { // Handle Exception } catch(TimeoutException ex) { // Handle Exception } catch(Exception ex) { // Handle Exception } } return

What happens when a fault occurs during stack unwinding on Windows?

柔情痞子 提交于 2019-12-11 00:50:35
问题 What happens when a fault occurs during the SEH stack unwinding on Windows? For example, if the unwind info is corrupted or incorrect, or the stack has been overwritten with invalid data, and a GP fault occurs during the unwind process? Is the diagnostic dialog still presented to the user or is there a different behavior in this case? 来源: https://stackoverflow.com/questions/45335145/what-happens-when-a-fault-occurs-during-stack-unwinding-on-windows

An existing connection was forcibly closed by the remote host in SMTP client

萝らか妹 提交于 2019-12-11 00:17:12
问题 I am about to give up debugging SMTP servers to send email... My code is the following SmtpClient mailClient = new SmtpClient("plus.smtp.mail.yahoo.com", 465); mailClient.EnableSsl = true; MailMessage message = new MailMessage(); message.To.Add("aditya15417@hotmail.com"); message.Subject = "permias-tucson-contact-us"; mailClient.Credentials = new NetworkCredential("myemail@yahoo.com", "mypassword"); MailAddress fromAddress = new MailAddress(Email.Text, Name.Text); message.From = fromAddress;