Search Results

Search found 36003 results on 1441 pages for 'try catch'.

Page 18/1441 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • How can a client try to reconnect to a server after a first failed try with WCF?

    - by djerry
    Hey guys, I'm using a client - server app. When a client starts, he gets a login-screen. When the server is not up yet, the call to the server will throw an exception which i catch (EndpointNotFoundException). I show a messagebox telling the user the server is offline. When he tries to reconnect again, it will throw another exception (CommunicationObjectFaultedException), even though the server is online. When a new client starts then, he can connect to the server. But the client who attempted before, still gets the error. My question now is how can the first client login after a failed first try without having to start his program again. So i want to clear the communicationchannel of its faulted state or something like that. Thanks in advance.

    Read the article

  • How to get the name of the method that caused the exception

    - by SKumar
    My code looks as below. try { _productRepo.GetAllProductCategories(); } catch (Exception ex) { //Do Something } I need a way to show the method name, suppose in the above case if any exception is thrown in the GetAllProductCategories() method, I need to get this method name i.e. "GetAllProductCategories()" as my result. Can any one suggest me how to do this?

    Read the article

  • i try to combine GUI with class - no success

    - by Gold
    hi i made a class that make registration to my WinCE program. how i can from the class draw pannel + textbox, and catch the enter press from the textbox ? i try to do this: TextBox tb=new TextBox(); tb.Location=new Point(10,10); Panel pn=new Panel(); pn.Dock=DockStyle.Fill; pn.Controls.Add(tb); this.Controls.Add(pn); but i got error in: this.Controls.Add(pn); is there any simple sample code for this ? thank's in advance

    Read the article

  • Why use try … finally without a catch clause?

    - by Nick Rosencrantz
    The classical way to program is with try / catch but when is it appropriate to use try without catch? In Python the following appears legal and can make sense: try: #do work finally: #do something unconditional But we didn't catch anything. Similarly one could think in Java it would be try { //for example try to get a database connection } finally { //closeConnection(connection) } It looks good and suddenly I don't have to worry about exception types etc. But if this is good practice, when is it good practice? Or reasons why this is not good practice or not legal (I didn't compile the source I'm asking about and it could be a syntax error for Java but I checked that the Python surely compiles.) A related problem I've run into is that I continue writing the function / method and at the end I must return something and I'm in a place which should not be reached and it must be a return point so even if I handle the exceptions above I'm still returning null or an empty string at some point in the code which should not be reached, often the end of the method / function. I've always managed to restructure to code so that I don't have to return null since that absolutely appears to look like less than good practice.

    Read the article

  • SAP Business One: Connection Error When I try to connect to UI API

    - by RedsDevils
    Hi All, I got this error message "Connection - Could not find SBO that match the connection string [66000-85]" when I try to connect SAP Business One UI API. I connect like the following : private void SetApplication() { SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = null; SboGuiApi = new SAPbouiCOM.SboGuiApi(); // connect to a running SBO Application sConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString() ; SboGuiApi.Connect(sConnectionString); SBO_Application = SboGuiApi.GetApplication(-1); }

    Read the article

  • When I try to show an image on linklabel click, I get an error

    - by JB
    When I try to show an image on linklabel click, I get an error: unrecognized escape sequence. Code: public void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process.Start( "mspaint~C:\Users\Joshua Banks\Desktop\Downtown_atlanta_night.jpg"); }

    Read the article

  • Blogger GData NullPointerException on every second try on Android

    - by Vinay
    I am experiencing a strange phenomenon with Blogger GData API 2.0 on Android. I am using the BloggerService to retrieve blogs. First time it works fine. However EVERY SECOND TRY I get a NullPointerException: Caused by: java.lang.NullPointerException at com.google.gdata.wireformats.AltRegistry.lookupType(AltRegistry.java:190) at com.google.gdata.client.Service.parseResponseData(Service.java:1860) at com.google.gdata.client.Service.getFeed(Service.java:1054) at com.google.gdata.client.Service.getFeed(Service.java:916) at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:631) at com.google.gdata.client.Service.getFeed(Service.java:935)

    Read the article

  • try finally in ant

    - by Grzenio
    Hi, In my ant script, which runs the end-to-end integration tests, I first start a process, then do some other stuff, then run the tests, and then I need to make sure I kill the process. However, I need to make sure I kill the process even if something fails (so I need an equivalent to try finally). What is the recommended way of doing it?

    Read the article

  • Try method in powershell

    - by Willy
    So I want to build a try method into my powershell script below. If I am denied access to a server, I want it to skip that server. Please help.. [code]$Computers = "server1", "server2" Get-WmiObject Win32_LogicalMemoryConfiguration -Computer $Computers | Select-Object ` @{n='Server';e={ $_.__SERVER }}, ` @{n='Physical Memory';e={ "$('{0:N2}' -f ($_.TotalPhysicalMemory / 1024))mb" }}, ` @{n='Virtual Memory';e={ "$('{0:N2}' -f ($_.TotalPageFileSpace / 1024))mb" }} | ` Export-CSV "output.csv"[/code]

    Read the article

  • Python: if key in dict vs. try/except

    - by LeeMobile
    I have a question about idioms and readability, and there seems to be a clash of Python philosophies for this particular case: I want to build dictionary A from dictionary B. If a specific key does not exist in B, then do nothing and continue on. Which way is better? try: A["blah"] = B["blah"] except KeyError: pass or if "blah" in B: A["blah"] = B["blah"] "Do and ask for forgiveness" vs. "simplicity and explicitness". Which is better and why?

    Read the article

  • Visual Studio 2012 crashes everytime I try to debug with error CLR20r3

    - by Chris
    Everytime I try to debug one of my apps I get the below error message. Anyone have any ideas? I tried running Visual Studio in safe mode but I get the same thing. I also tried to repair the install and completely reinstall it with no luck :(. The full Problem Signature is this: Problem signature: Problem Event Name: CLR20r3 Problem Signature 01: devenv.exe Problem Signature 02: 11.0.50727.1 Problem Signature 03: 5011ecaa Problem Signature 04: Microsoft.IntelliTrace.Package.11.0.0 Problem Signature 05: 11.0.50727.1 Problem Signature 06: 5011dad8 Problem Signature 07: 311 Problem Signature 08: 1f1 Problem Signature 09: System.AccessViolationException OS Version: 6.1.7601.2.1.0.256.48 Locale ID: 1033 Additional Information 1: 0a9e Additional Information 2: 0a9e372d3b4ad19135b953a78882e789 Additional Information 3: 0a9e Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

    Read the article

  • Increasing coverage with try-except-finally and a context-manager

    - by Daan Timmer
    This is the flow that I have in my program 277: try: 278: with open(r"c:\afile.txt", "w") as aFile: ...: pass # write data 329: except IOError as ex: ...: print ex 332: finally: 333: if os.path.exists(r"c:\afile.txt"): 334: shutil.copy(r"c:\afile.txt", r"c:\dest.txt") I've got all paths covered except for from line 278 to line 333 I got a normal happy-flow. I stubbed __builtin__.open to raise IOError when the open is called with said file name But how do I go from 278 to 333. Is this even possible? Additional information: - using coverage.py 3.4 (only listing 3.5, we can't currently upgrade to 3.5)

    Read the article

  • when i try to save this file it creates and folder for the entire path

    - by girish
    ZipFileToCreate = "c:\user\desktop\webservice\file.zip"; so, when i try to save this file it creates the folder for the path like user\desktop\webservice\file\ why is it so, FileStream fs = new FileStream(ZipFileToCreate, FileMode.Open); byte[] data = new Byte[fs.Length]; BinaryReader br = new BinaryReader(fs); br.Read(data, 0, data.Length); br.Close(); Response.Clear(); Response.ContentType = "application/x-zip-compressed"; Response.AppendHeader("Content-Disposition", "filename=" + Parameter + ".zip"); DeleteOldFiles(); Response.BinaryWrite(data);

    Read the article

  • try...else...except syntax error

    - by iform
    I can't understand this... Cannot get this code to run and I've no idea why it is a syntax error. try: newT.read() #existingArtist = newT['Exif.Image.Artist'].value #existingKeywords = newT['Xmp.dc.subject'].value except KeyError: print "KeyError" else: #Program will NOT remove existing values newT.read() if existingArtist != "" : newT['Exif.Image.Artist'] = artistString print existingKeywords keywords = os.path.normpath(relativePath).split(os.sep) print keywords newT['Xmp.dc.subject'] = existingKeywords + keywords newT.write() except: print "Cannot write tags to ",filePath Syntax error occurs on the last "except:". Again...I have no idea why python is throwing a syntax error (spent ~3hrs on this problem).

    Read the article

  • Catching constraint violations in JPA 2.0.

    - by Dennetik
    Consider the following entity class, used with, for example, EclipseLink 2.0.2 - where the link attribute is not the primary key, but unique nontheless. @Entity public class Profile { @Id private Long id; @Column(unique = true) private String link; // Some more attributes and getter and setter methods } When I insert records with a duplicate value for the link attribute, EclipseLink does not throw a EntityExistsException, but throws a DatabaseException, with the message explaining that the unique constraint was violated. This doesn't seem very usefull, as there would not be a simple, database independent, way to catch this exception. What would be the advised way to deal with this? A few things that I have considered are: Checking the error code on the DatabaseException - I fear that this error code, though, is the native error code for the database; Checking the existence of a Profile with the specific value for link beforehand - this obviously would result in an enormous amount of superfluous queries.

    Read the article

  • Python try/except: Showing the cause of the error after displaying my variables

    - by NealWalters
    I'm not even sure what the right words are to search for. I want to display parts of the error object in an except block (similar to the err object in VBScript, which has Err.Number and Err.Description). For example, I want to show the values of my variables, then show the exact error. Clearly, I am causing a divided-by-zero error below, but how can I print that fact? try: x = 0 y = 1 z = y / x z = z + 1 print "z=%d" % (z) except: print "Values at Exception: x=%d y=%d " % (x,y) print "The error was on line ..." print "The reason for the error was ..."

    Read the article

  • try except block in Delphi

    - by Nik
    Do you guys know a way to trap log and re-raise exception in Delphi code. A simple example: procedure TForm3.Button1Click(Sender: TObject); begin try raise Exception.Create('Bum'); except on E: Exception do begin MyHandleException(E); end; end; end; procedure TForm3.MyHandleException(AException: Exception); begin ShowMessage(AException.Message); // raise AException; - this will access violate end; So I need to re-raise it in the except block but I was wondering is there a better way to write my own method to handle and (on specific conditions) to re-raise exceptions?

    Read the article

  • Exception from within a finally block

    - by schrödingers cat
    Consider the following code where LockDevice() could possibly fail and throw an exception on ist own. What happens in C# if an exception is raised from within a finally block? UnlockDevice(); try { DoSomethingWithDevice(); } finally { LockDevice(); // can fail with an exception }

    Read the article

  • Exchange Web Services, try to use ExchangeImpersonationType ...

    - by howmanytimes
    I am trying to use EWS, first time trying to use the ExchangeServiceBinding. The code I am using is below: _service = new ExchangeServiceBinding(); //_service.Credentials = new NetworkCredential(userName, userPassword, this.Domain); _service.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; _service.Url = this.ServiceURL; ExchangeImpersonationType ei = new ExchangeImpersonationType(); ConnectingSIDType sid = new ConnectingSIDType(); sid.PrimarySmtpAddress = this.ExchangeAccount; ei.ConnectingSID = sid; _service.ExchangeImpersonation = ei; The application is an aspnet 3.5 trying to create a task using EWS. I have tried to use impersonation because I will not know the logon user's domain password, so I thought impersonation would be the best fit. Any thoughts on how I can utilize impersonation? Am I setting this correctly, I get an error while trying to run my application. I also tried without impersonation just to try to see if I can create a task, no luck either. Any help would be appreciated. Thanks.

    Read the article

  • PHP: If no Results - Split the Searchrequest and Try to find Parts of the Search

    - by elmaso
    Hello, i want to split the searchrequest into parts, if there's nothing to find. example: "nelly furtado ft. jimmy jones" - no results - try to find with nelly, furtado, jimmy or jones.. i have an api url.. thats the difficult part.. i show you some of the actually snippets: $query = urlencode (strip_tags ($_GET[search])); and $found = '0'; if ($source == 'all') { if (!($res = @get_url ('http://api.example.com/?key=' . $API . '&phrase=' . $query . ' . '&sort=' . $sort))) { exit ('<error>Cannot get requested information.</error>'); ; } how can i put a else request in this snippet, like if nothing found take the first word, or the second word, is this possible? or maybe you can tell me were i can read stuff about this function? thank you!!

    Read the article

  • Mahout - Error when try out wikipedia exmaples

    - by Li'
    Note this post is similar to Caused by: java.lang.ClassNotFoundException: classpath but different error message. When I try to run Wikipedia Bayes Example from https://cwiki.apache.org/confluence/display/MAHOUT/Wikipedia+Bayes+Example When I ran the following command : lis-macbook-pro:mahout-distribution-0.8 Li$ mahout wikipediaXMLSplitter -d examples/temp/enwiki-latest-pages-articles10.xml -o wikipedia/chunks -c 64 I got error message: MAHOUT_LOCAL is set, so we don't add HADOOP_CONF_DIR to classpath. MAHOUT_LOCAL is set, running locally SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/Users/Li/File/Java/mahout-distribution-0.8/examples/target/mahout-examples-0.8-job.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/Users/Li/File/Java/mahout-distribution-0.8/examples/target/dependency/slf4j-jcl-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.JCLLoggerFactory] Oct 21, 2013 4:25:47 PM org.slf4j.impl.JCLLoggerAdapter warn WARNING: Unable to add class: wikipediaXMLSplitter java.lang.ClassNotFoundException: wikipediaXMLSplitter at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:171) at org.apache.mahout.driver.MahoutDriver.addClass(MahoutDriver.java:236) at org.apache.mahout.driver.MahoutDriver.main(MahoutDriver.java:127) I am using Hadoop 1.2 and Mahout 0.8. mahout-distribution-0.8/bin has been added to $PATH. $MAHOUT_LOCAL is set to "True", so it runs locally. I dont know why I got "Unable to add class: wikipediaXMLSplitter"

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >