Search Results

Search found 13011 results on 521 pages for 'catch block'.

Page 125/521 | < Previous Page | 121 122 123 124 125 126 127 128 129 130 131 132  | Next Page >

  • Text goes goes into separate lines when using a percentage padding

    - by Haxed
    Hi, I have a small problem in html forms. When I give the following css, .row .section-1 label {/* Formatting all section-1 labels */ padding: 0 5px 0 10px; margin: 3px 0 0 0; display:block; } This is the output that I get : However when I edit the css to put padding in the form of a percentage: .row .section-1 label {/* Formatting all section-1 labels */ padding: 0 40% 0 80%; margin: 3px 0 0 0; display: block; } This is the output I get : I want to use percentages, however I want the look in the first image. Any ideas?? Thanks

    Read the article

  • How to populate JList with data from another JList

    - by Zhen Le
    I have a MySQL database which contains data i would like to populate into a JList in my java program. I have two JList, one which is fill with Events Title and the second is to be fill with Guest Name. What i would like is when the user click on any of the Events Title, the second JList will show all the Guest Name that belong to that Event. I have already successfully populate the first JList with all the Events Title. What I'm having trouble with is when the user click on the Events Title, the Guests Name will show twice on the second JList. How can i make it to show only once? Here is what i got so far... Java Class private JList getJListEvents() { if (jListEvents == null) { jListEvents = new JList(); Border border = BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(1, Color.black, Color.black), "Events", TitledBorder.LEFT, TitledBorder.TOP); jListEvents.setBorder(border); jListEvents.setModel(new DefaultListModel()); jListEvents.setBounds(new Rectangle(15, 60, 361, 421)); Events lEvents = new Events(); lEvents.loadEvents(jListEvents); jListEvents.addListSelectionListener(new ListSelectionListener(){ public void valueChanged(ListSelectionEvent e){ EventC eventC = new EventC(); //eventC.MonitorRegDetailsInfo(jListEvents, jTextFieldEventName, jTextFieldEventVenue, jTextFieldEventDate, jTextFieldEventTime, jTextAreaEventDesc); //eventC.MonitorRegPackageInfo(jListEvents, jTextFieldBallroom, jTextFieldBallroomPrice, jTextFieldMeal, jTextFieldMealPrice, jTextFieldEntertainment, jTextFieldEntertainmentPrice); eventC.MonitorRegGuest(jListEvents, jListGuest); } }); } return jListEvents; } Controller Class public void MonitorRegGuest(JList l, JList l2){ String event = l.getSelectedValue().toString(); Events retrieveGuest = new Events(event); retrieveGuest.loadGuests(l2); } Class with all the sql statement public void loadGuests(JList l){ ResultSet rs = null; ResultSet rs2 = null; ResultSet rs3 = null; MySQLController db = new MySQLController(); db.getConnection(); String sqlQuery = "SELECT MemberID FROM event WHERE EventName = '" + EventName + "'"; try { rs = db.readRequest(sqlQuery); while(rs.next()){ MemberID = rs.getString("MemberID"); } } catch (SQLException e) { e.printStackTrace(); } String sqlQuery2 = "SELECT GuestListID FROM guestlist WHERE MemberID = '" + MemberID + "'"; try { rs2 = db.readRequest(sqlQuery2); while(rs2.next()){ GuestListID = rs2.getString("GuestListID"); } } catch (SQLException e) { e.printStackTrace(); } String sqlQuery3 = "SELECT Name FROM guestcontact WHERE GuestListID = '" + GuestListID + "'"; try { rs3 = db.readRequest(sqlQuery3); while(rs3.next()){ ((DefaultListModel)l.getModel()).addElement(rs3.getString("Name")); } } catch (SQLException e) { e.printStackTrace(); } db.terminate(); } Thanks in advance!

    Read the article

  • problems calling webservices through the https connection

    - by shivaji123
    i have done an application in BlackBerry which takes username & password with url link which is a link of server here i am calling some webservices but it is doing the connection in https so when i take the username password & url link & hit the login button it basically calls a webservice but then the application connecting to the webservice for ever & after some time i get the error massage something "unreported exception the application is not responding" .& then the application crashes out.Also i am using the SOAP client library . this is the piece of code synchronized (this) { try { _httpconn = (HttpConnection) Connector.open(url,Connector.READ_WRITE);//Connector.READ_WRITE //_httpconn =(StreamConnection)Connector.open(url); //System.out.println("-----------httpsconnection() PART--------------------"); _httpconn.setRequestMethod(HttpConnection.POST); //_httpconn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); //System.out.println("-----------httpsconnection() PART- **-------------------"); _httpconn.setRequestProperty("SOAPAction", Constants.EXIST_STR); //System.out.println("-----------httpsconnection() PART-REQUEST -------------------"); _httpconn.setRequestProperty("Content-Type", "text/soap+xml"); //System.out.println("-----------httpsconnection() PART- CONTENT-------------------"); _httpconn.setRequestProperty("User-Agent", "kSOAP/1.0"); //System.out.println("-----------httpsconnection() PART-USER Agent-------------------"); String clen = Integer.toBinaryString(input.length()); _httpconn.setRequestProperty("Content-Length", clen); //System.out.println("-----------httpsconnection() Content-Length--------------------"); _out = _httpconn.openDataOutputStream(); //System.out.println(input+"-----------input--------------------"+url); _out.write(input.getBytes()); _out.flush(); // may or may not be needed. //int rc = _httpconn.getResponseCode(); int rc = _httpconn.getResponseCode(); if(rc == HttpConnection.HTTP_OK) { isComplete = true; _in = _httpconn.openInputStream(); msg = new StringBuffer(); byte[] data = new byte[1024]; int len = 0; int size = 0; while ( -1 != (len = _in.read(data)) ) { msg.append(new String(data, 0, len)); size += len; } responsData = msg.toString(); System.out.println("-----------responsData "+responsData); } if(responsData!=null) isSuccessful = true; stop(); } catch (InterruptedIOException interrIO) { //errStr = "Network Connection hasn't succedded. "+ //"Please check APN setting."; UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show("Network Connection hasn't succedded. "+ "Please try again later."); } }); isComplete = true; System.out.println(interrIO); stop(); } catch (IOException interrIO) { System.out.println("-----------IO EXCEPTION--------- "+interrIO); //errStr = "Network Connection hasn't succedded. "+ //"Please check APN setting." ; UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show("Network Connection hasn't succedded. "+ "Please try again later." ); } }); isComplete = true; System.out.println(interrIO); stop(); } catch (Exception e) { System.out.println(e); //errStr = "Unable to connect to the internet at this time. "+ //"Please try again later."; UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show("Unable to connect to the internet at this time. "+ "Please try again later." ); } }); isComplete = true; stop(); } finally { try { if(_httpconn != null) { _httpconn.close(); _httpconn = null; } if(_in != null) { _in.close(); _in = null; } if(_out != null) { _out.close(); _out = null; } } catch(Exception e) { System.out.println(e); UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show("Unable to connect to the internet at this time. "+ "Please try again later." ); } }); } } } } can anybody help me out. Thanks in advance

    Read the article

  • What is the suggested way to show exception messages on UI which were produced in Business Layer?

    - by burak ozdogan
    Hi, Is there a pattern OR 'a best practice' on creating user's friendly messages in the presentation layer by using exceptions which were thrown from the Business Layer? Actually in many cases I prefer to throw Application Exceptions and this is forcing me to catch them on UI (aspx.cs pages). And if the process is complex which may produce many different types of exceptions I have to have many catch blocks to produce specific error messages. Is there a better way coming to your mind? A pattern maybe for similar cases? thanks

    Read the article

  • Resuming execution of code after exception is thrown and caught

    - by dotnetdev
    Hi, How is it possible to resume code execution after an exception is thrown? For exampel, take the following code: namespace ConsoleApplication1 { class Test { public void s() { throw new NotSupportedException(); string @class = "" ; Console.WriteLine(@class); Console.ReadLine(); } } class Program { static void Main(string[] args) { try { new Test().s(); } catch (ArgumentException x) { } catch (Exception ex) { } } } } After catching the exception when stepping through, the program will stop running. How can I still carry on execution? Thanks

    Read the article

  • Align table columns HTML

    - by Luigi Tiburzi
    I finally was able to align the columns in the tables of a page of my website. Though I found the solution I don't understand it. This is a fiddle I prepared. If you delete display: block from the CSS the columns are centered perfectly. The fact is that I don't understand what that instruction is causing problems, doesn't it means that elements are displayed as block elements? Shouldn't it cause the elements (the raw in particular) to fill an entire line? Thanks for your explanation

    Read the article

  • jaxb unmarshal problem

    - by Hoax
    private JAXBContext jaxbContext; private Marshaller marshaller; private Unmarshaller unmarshaller; private PoiList db; public XMLHandler() { try { JAXBContext.newInstance("x.y.shared"); } catch (JAXBException e) { e.printStackTrace(); } } public PoiList readXML() { try { unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setEventHandler(new XMLValidEventHandler()); db = (PoiList) unmarshaller.unmarshal(new File("src/source.xml")); } catch (JAXBException e) { e.printStackTrace(); } return db; } gets me this Exception in thread "main" java.lang.NullPointerException at com.sem.server.XMLHandler.readXML(XMLHandler.java:32) at sem.server.testDataAPI.main(testDataAPI.java:13) Line 32 in this case is the jaxbContext.createUnmarshaller() Line. packages are x.y.client x.y.server (includes the XMLHandler) x.y.shared (includes jaxb generated classes) not really sure what the problem is. any help is appreciated!

    Read the article

  • How do i return a StringWriter When I cant Clone it?

    - by acidzombie24
    My code looks like the below. Obviously i cant write 'ok' because the object has been disposed. I cant do return sw.Clone() bc clone doesnt exist. If i dont use a using then at any point between = new and return (like iterating and writing to the object as my example doesnt do) can have an exception and thus not disposing the object. Am i to define sw outside of a try block and check if its null then dispose in a catch block? That seems like a bit of excessive work. Is there a better way? is that the only way? static void func1() { using (var sw = func2()) { sw.WriteLine("Ok"); } } static StringWriter func2() { using (var sw = new StringWriter()) { return sw; } }

    Read the article

  • Decryption Key value not match

    - by Jitendra Jadav
    public class TrippleENCRSPDESCSP { public TrippleENCRSPDESCSP() { } public void EncryptIt(string sData,ref byte[] sEncData,ref byte[] Key1,ref byte[] Key2) { try { // Create a new TripleDESCryptoServiceProvider object // to generate a key and initialization vector (IV). TripleDESCryptoServiceProvider tDESalg = new TripleDESCryptoServiceProvider(); // Create a string to encrypt. // Encrypt the string to an in-memory buffer. byte[] Data = EncryptTextToMemory(sData,tDESalg.Key,tDESalg.IV); sEncData = Data; Key1 = tDESalg.Key; Key2 = tDESalg.IV; } catch (Exception) { throw; } } public string DecryptIt(byte[] sEncData) { //byte[] toEncrypt = new ASCIIEncoding().GetBytes(sEncData); //XElement xParser = null; //XmlDocument xDoc = new XmlDocument(); try { //string Final = ""; string sPwd = null; string sKey1 = null; string sKey2 = null; //System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); string soutxml = ""; //soutxml = encoding.GetString(sEncData); soutxml = ASCIIEncoding.ASCII.GetString(sEncData); sPwd = soutxml.Substring(18, soutxml.LastIndexOf("</EncPwd>") - 18); sKey1 = soutxml.Substring(18 + sPwd.Length + 15, soutxml.LastIndexOf("</Key1>") - (18 + sPwd.Length + 15)); sKey2 = soutxml.Substring(18 + sPwd.Length + 15 + sKey1.Length + 13, soutxml.LastIndexOf("</Key2>") - (18 + sPwd.Length + 15 + sKey1.Length + 13)); //xDoc.LoadXml(soutxml); //xParser = XElement.Parse(soutxml); //IEnumerable<XElement> elemsValidations = // from el in xParser.Elements("EmailPwd") // select el; #region OldCode //XmlNodeList objXmlNode = xDoc.SelectNodes("EmailPwd"); //foreach (XmlNode xmllist in objXmlNode) //{ // XmlNode xmlsubnode; // xmlsubnode = xmllist.SelectSingleNode("EncPwd"); // xmlsubnode = xmllist.SelectSingleNode("Key1"); // xmlsubnode = xmllist.SelectSingleNode("Key2"); //} #endregion //foreach (XElement elemValidation in elemsValidations) //{ // sPwd = elemValidation.Element("EncPwd").Value; // sKey1 = elemValidation.Element("Key1").Value; // sKey2 = elemValidation.Element("Key2").Value; //} //byte[] Key1 = encoding.GetBytes(sKey1); //byte[] Key2 = encoding.GetBytes(sKey2); //byte[] Data = encoding.GetBytes(sPwd); byte[] Key1 = ASCIIEncoding.ASCII.GetBytes(sKey1); byte[] Key2 = ASCIIEncoding.ASCII.GetBytes(sKey2); byte[] Data = ASCIIEncoding.ASCII.GetBytes(sPwd); // Decrypt the buffer back to a string. string Final = DecryptTextFromMemory(Data, Key1, Key2); return Final; } catch (Exception) { throw; } } public static byte[] EncryptTextToMemory(string Data,byte[] Key,byte[] IV) { try { // Create a MemoryStream. MemoryStream mStream = new MemoryStream(); // Create a CryptoStream using the MemoryStream // and the passed key and initialization vector (IV). CryptoStream cStream = new CryptoStream(mStream, new TripleDESCryptoServiceProvider().CreateEncryptor(Key, IV), CryptoStreamMode.Write); // Convert the passed string to a byte array. //byte[] toEncrypt = new ASCIIEncoding().GetBytes(Data); byte[] toEncrypt = ASCIIEncoding.ASCII.GetBytes(Data); // Write the byte array to the crypto stream and flush it. cStream.Write(toEncrypt, 0, toEncrypt.Length); cStream.FlushFinalBlock(); // Get an array of bytes from the // MemoryStream that holds the // encrypted data. byte[] ret = mStream.ToArray(); // Close the streams. cStream.Close(); mStream.Close(); // Return the encrypted buffer. return ret; } catch (CryptographicException e) { MessageBox.Show("A Cryptographic error occurred: {0}", e.Message); return null; } } public static string DecryptTextFromMemory(byte[] Data, byte[] Key, byte[] IV) { try { // Create a new MemoryStream using the passed // array of encrypted data. MemoryStream msDecrypt = new MemoryStream(Data); // Create a CryptoStream using the MemoryStream // and the passed key and initialization vector (IV). CryptoStream csDecrypt = new CryptoStream(msDecrypt, new TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV), CryptoStreamMode.Write); csDecrypt.Write(Data, 0, Data.Length); //csDecrypt.FlushFinalBlock(); msDecrypt.Position = 0; // Create buffer to hold the decrypted data. byte[] fromEncrypt = new byte[msDecrypt.Length]; // Read the decrypted data out of the crypto stream // and place it into the temporary buffer. msDecrypt.Read(fromEncrypt, 0, msDecrypt.ToArray().Length); //csDecrypt.Close(); MessageBox.Show(ASCIIEncoding.ASCII.GetString(fromEncrypt)); //Convert the buffer into a string and return it. return new ASCIIEncoding().GetString(fromEncrypt); } catch (CryptographicException e) { MessageBox.Show("A Cryptographic error occurred: {0}", e.Message); return null; } } }

    Read the article

  • How to display specific data from a file

    - by user1067332
    My program is supposed to ask the user for firstname, lastname, and phone number till the users stops. Then when to display it asks for the first name and does a search in the text file to find all info with the same first name and display lastname and phones of the matches. import java.util.*; import java.io.*; import java.util.Scanner; public class WritePhoneList { public static void main(String[] args)throws IOException { BufferedWriter output = new BufferedWriter(new FileWriter(new File( "PhoneFile.txt"), true)); String name, lname, age; int pos,choice; try { do { Scanner input = new Scanner(System.in); System.out.print("Enter First name, last name, and phone number "); name = input.nextLine(); output.write(name); output.newLine(); System.out.print("Would you like to add another? yes(1)/no(2)"); choice = input.nextInt(); }while(choice == 1); output.close(); } catch(Exception e) { System.out.println("Message: " + e); } } } Here is the display code, when i search for a name, it finds a match but displays the last name and phone number of the same name 3 times, I want it to display all of the possible matches with the first name. import java.util.*; import java.io.*; import java.util.Scanner; public class DisplaySelectedNumbers { public static void main(String[] args)throws IOException { String name; String strLine; try { FileInputStream fstream = new FileInputStream("PhoneFile.txt"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); Scanner input = new Scanner(System.in); System.out.print("Enter a first name"); name = input.nextLine(); strLine= br.readLine(); String[] line = strLine.split(" "); String part1 = line[0]; String part2 = line[1]; String part3 = line[2]; //Read File Line By Line while ((strLine= br.readLine()) != null) { if(name.equals(part1)) { // Print the content on the console System.out.print("\n" + part2 + " " + part3); } } }catch (Exception e) {//Catch exception if any System.out.println("Error: " + e.getMessage()); } } }

    Read the article

  • How to break on unhandled exceptions in Silverlight

    - by Bruno Martinez
    In console .Net applications, the debugger breaks at the point of the throw (before stack unwinding) for exceptions with no matching catch block. It seems that Silverlight runs all user code inside a try catch, so the debugger never breaks. Instead, Application.UnhandledException is raised, but after catching the exception and unwinding the stack. To break when unhandled exceptions are thrown and not catched, I have to enable first chance exception breaks, which also stops the program for handled exceptions. Is there a way to remove the Silverlight try block, so that exceptions get directly to the debugger?

    Read the article

  • My Thread Programs Crash

    - by zp26
    I have a problem with threads objectiveC. The line of code below contains the recv block the program waiting for a datum. My intention is to launch a thread parallel to the program so that this statement does not block any application. I put this code in my program but when active switch the program crashes. Enter the code. -(IBAction)Chat{ if(switchChat.on){ buttonInvio.enabled = TRUE; fieldInvio.enabled = TRUE; [NSThread detachNewThreadSelector:@selector(riceviDatiServer) toTarget:self withObject:nil]; } else { buttonInvio.enabled = FALSE; fieldInvio.enabled = FALSE; } -(void)riceviDatiServer{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; int ricevuti; NSString *datiRicevuti; ricevuti = recv(temp, &datiRicevuti, datiRicevuti.length, 0); labelRicezione.text = [[NSString alloc] initWithFormat:@"%s.... %d", datiRicevuti, ricevuti]; [pool release]; }

    Read the article

  • The String source is unknown while using the parse methode!

    - by kawtousse
    Hi everyone, to parse a string to a date sql valid: SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date date = null; try { date = df.parse(dateimput); } catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } with dateimput is what i get from my form like that: String dateimput=request.getParameter("datepicker"); but when running see the error: java.text.ParseException: Format.parseObject(String) failed at java.text.Format.parseObject(Unknown Source) at ServletEdition.doPost(ServletEdition.java:70) so it mean that dateimput is not known + I note that it is correctly dislayed when: System.out.println("datepicker:" +dateimput); Thanks.

    Read the article

  • How 404 error asp.net mvc 2 IIS 7?

    - by Dmitriy
    Hello! I tried to catch 404 errors like this... But when i try to load http://localhost:11415/wfwe/wefwe/ - all good work. When i try to load http://localhost:11415/order/ - fail (with error The RouteData must contain an item named 'action' with a non-empty string value.) When i try to load http://localhost:11415/Images/ - fail with error File does not exist My routes: routes.Add("Order", new LowercaseRoute("Order/{action}/{id}", new RouteValueDictionary( new { controller = "Order", action = "", id = UrlParameter.Optional }), new MvcRouteHandler())); routes.Add("NotFound", new LowercaseRoute("{*url}", new RouteValueDictionary( new { controller = "Pages", action = "Http404", }), new MvcRouteHandler())); Why route NotFound - don't catch all 404 error. And When i try to upload to my hosting and try 404 i get this error (NotFound route not work at all) 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable. I work with this all day, but nothig... please help me

    Read the article

  • Determine if on product page programmatically in Magento

    - by dfondente
    I want to insert tracking codes on all of the pages of a Magento site, and need to use a different syntax if the page is a CMS page, a category browsing page, or a product view page. I have a custom module set up with a block that inserts a generic tracking code on each page for now. From within the block, how can I distinguish between CMS pages, category pages, and product pages? I started with: Mage::app()->getRequest(); I can see that Mage::app()->getRequest()->getParam('id'); returns the product or category ID on product and category pages, but doesn't distinguish between those page types. Mage::app()->getRequest()->getRouteName(); return "cms" for CMS pages, but returns "catalog" for both category browsing and product view pages, so I can't use that to tell category and product pages apart. Is there some indicator in the request I can use safely? Or is there a better way to accomplish my goal of different tracking codes for different page types?

    Read the article

  • _CrtDumpMemoryLeaks truncated output??

    - by Marin
    Hello, I am trying to use Visual Studio's capability to detect memory leaks, but I keep getting truncated output, like: Dumping objects -> {174} normal block at 0x0099ADB8, 48 bytes long. Data: <h:\najnovije\tru> 68 3A 5C 6E 61 6A 6E 6F 76 69 6A 65 5C 74 72 75 {170} normal block at 0x0099AD58, 32 bytes long. Data: <h:\najnovije\tru> 68 3A 5C 6E 61 6A 6E 6F 76 69 6A 65 5C 74 72 75 Object dump complete. What am I doing wrong? I added #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> to the beginning of my code. Thank you.

    Read the article

  • Few doubts regarding Bitmaps , Images & `using` blocks

    - by imageWorker
    I caught up in this problem. http://stackoverflow.com/questions/2559826/garbage-collector-not-doing-its-job-memory-consumption-1-5gb-outofmemory-exc I feel that there is something wrong in my understanding. Please clarify these things. Destructor & IDisposable.Dispose are two methods for freeing resources that are not not under the control of .NET. Which means, everything except memory. right? using blocks are just better way of calling IDisposable.Dispose() method of an object. This is the main code I'm referring to. class someclass { static someMethod(Bitmap img) { Bitmap bmp = new Bitmap(img); //statement1 // some code here and return } } here is class I'm using for testing: class someotherClass { public static voide Main() { foreach (string imagePath in imagePathsArray) { using (Bitmap img1 = new Bitmap(imagePath)) { someclass.someMethod(img1); // does some more processing on `img1` } } } } Is there any memory leak with statement1? Question1: If each image size is say 10MB. Then does this bmp object occupy atleast 10MB? What I mean is, will it make completely new copy of entire image? or just refer to it? Question2:should I or should I not put the statement1 in using block? My Argument: We should not. Because using is not for freeing memory but for freeing the resources (file handle in this case). If I use it in using block. It closes file handle here encapsulated by this bmp object. It means we are also closing filehandle for the caller's img1 object. Which is not correct? As of the memory leak. No there is no scope of memory leak here. Because reference bmp is destroyed when this method is returned. Which leaves memory it refered without any pointer. So, its garbage collected. Am I right? Edit: class someclass { static Bitmap someMethod(Bitmap img) { Bitmap bmp = new Bitmap(img); //can I use `using` block on this enclosing `return bmp`; ??? // do some processing on bmp here return bmp; } }

    Read the article

  • F# pattern matching when mixing DU's and other values

    - by Roger Alsing
    What would be the most effective way to express the following code? match cond.EvalBool() with | true -> match body.Eval() with | :? ControlFlowModifier as e -> match e with | Break(scope) -> e :> obj //Break is a DU element of ControlFlowModifier | _ -> next() //other members of CFM should call next() | _ -> next() //all other values should call next() | false -> null cond.EvalBool returns a boolean result where false should return null and true should either run the entire block again (its wrapped in a func called next) or if the special value of break is found, then the loop should exit and return the break value. Is there any way to compress that block of code to something smaller?

    Read the article

  • C#: When should I use TryParse?

    - by zxcvbnm
    I understand it doesn't throw an Exception and because of that it might be sightly faster, but also, you're most likely using it to convert input to data you can use, so I don't think it's used so often to make that much of difference in terms of performance. Anyway, the examples I saw are all along the lines of an if/else block with TryParse, the else returning an error message. And to me, that's basically the same thing as using a try/catch block with the catch returning an error message. So, am I missing something? Is there a situation when this is actually useful?

    Read the article

  • custom DB logging using enterprise library 4.1

    - by Rohit
    We have to create a historical log of all the changed entities. we have defined our custom tables for this purpose. I have to incorporate this tables in Enterprise library logging block and do logging in these tables. I need to write a SP to insert values to these tables. Till now,what i have got from google is that i have to create a listener inheriting from CustomTraceListener and give my implementation of WriteMessage. What i need to know is,how will i plug my tables and SP in Enterprise library logging block.

    Read the article

  • How do I safely Debug.Assert in ASP.NET?

    - by MatthewMartin
    Asserts can't be caught. This is good because some errors I don't want to be wrapped in try/catch, at least not on the development server. But Asserts seem awefully dangerous. If they get onto production, it can hang the ASP.NET server with a msgbox. //Don't want this on prod even if debug=true is in the web.config #if DEBUG //A future client programmer can wrap this in a try{}catch{} if (!EverythingIsOkay) throw new InvalidOperationException("Dagnabbit, programming error"); //This stops the but has less information that an // Exception and hangs the server if this accidentally // runs on production System.Diagnostics.Debug.Assert(!EverythingIsOkay); #endif Is there better way to communicate an violation of a inviolable condition to a developer without risking hanging IIS? UPDATE: After reading the first replies, I guess the answer hinges on a foolproof way to detect when code is running in a development environment and when it is on a production server, or figuring out how to throw an exception that can't be caught and ignored.

    Read the article

  • Returning values from Swing using invokeAndWait

    - by Joonas Pulakka
    I've been using the following approach to create components and return values from Swing to/from outside the EDT. For instance, the following method could be an extension to JFrame, to create a JPanel and add it to the parent JFrame: public JPanel threadSafeAddPanel() { final JPanel[] jPanel = new JPanel[1]; try { EventQueue.invokeAndWait(new Runnable() { public void run() { jPanel[0] = new JPanel(); add(jPanel[0]); } }); } catch (InterruptedException ex) { } catch (InvocationTargetException ex) { } return jPanel[0]; } The local 1-length array is used to transfer the "result" from inside the Runnable, which is invoked in the EDT. Well, it looks "a bit" hacky, and so my questions: Does this make sense? Is anybody else doing something like this? Is the 1-length array a good way of transferring the result? Is there an easier way to do this?

    Read the article

  • New to asp.net. Need help debugging this email form.

    - by Roeland
    Hey guys, First of all, I am a php developer and most of .net is alien to me which is why I am posting here! I just migrated over a site from one set of webhosting to another. The whole site is written in .net. None of the site is database driven so most of it works, except for the contact form. The output on the site simple states there was an error with "There has been an error - please try to submit the contact form again, if you continue to experience problems, please notify our webmaster." This is just a simple message it pops out of it gets to the "catch" part of the email function. I went into web.config and changed the parameters: <emailaddresses> <add name="System" value="[email protected]"/> <add name="Contact" value="[email protected]"/> <add name="Info" value="[email protected]"/> </emailaddresses> <general> <add name="WebSiteDomain" value="hoyespharmacy.com"/> </general> Then the .cs file for contact contains the mail function EmailFormData(): private void EmailFormData() { try { StringBuilder body = new StringBuilder(); body.Append("Name" + ": " + txtName.Text + "\n\r"); body.Append("Phone" + ": " + txtPhone.Text + "\n\r"); body.Append("Email" + ": " + txtEmail.Text + "\n\r"); body.Append("Fax" + ": " + txtEmail.Text + "\n\r"); body.Append("Subject" + ": " + ddlSubject.SelectedValue + "\n\r"); body.Append("Message" + ": " + txtMessage.Text); MailMessage mail = new MailMessage(); mail.IsBodyHtml = false; mail.To.Add(new MailAddress(Settings.GetEmailAddress("System"))); mail.Subject = "Contact Us Form Submission"; mail.From = new MailAddress(Settings.GetEmailAddress("System"), Settings.WebSiteDomain); mail.Body = body.ToString(); SmtpClient smtpcl = new SmtpClient(); smtpcl.Send(mail); } catch { Utilities.RedirectPermanently(Request.Url.AbsolutePath + "?messageSent=false"); } } How do I see what the actual error is. I figure I can do something with the "catch" part of the function.. Any pointers? Thanks!

    Read the article

< Previous Page | 121 122 123 124 125 126 127 128 129 130 131 132  | Next Page >