Search Results

Search found 3773 results on 151 pages for 'args'.

Page 63/151 | < Previous Page | 59 60 61 62 63 64 65 66 67 68 69 70  | Next Page >

  • How can I set up .NET UnhandledException handling in a Windows service?

    - by Mike Pateras
    protected override void OnStart(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Thread.Sleep(10000); throw new Exception(); } void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { } I attached a debugger to the above code in my windows service, setting a breakpoint in CurrentDomain_UnhandledException, but it was never hit. The exception pops up saying that it is unhandled, and then the service stops. I even tried putting some code in the event handler, in case it was getting optimized away. Is this not the proper way to set up unhandled exception handling in a windows service?

    Read the article

  • Excel Interop: Range.FormatConditions.Add throws MissingMethodException

    - by Zach Johnson
    I am writing an application which uses the Microsoft.Office.Interop.Excel assembly to export/import data from Excel spreadsheets. Everything was going fine (except for 1 based indexing and all those optional parameters!), until I tried to use conditional formatting. When I call Range.FormatConditions.Add I get a MissingMethodException telling me that no such method exists. This happens in both Vista and XP. Here's an example of the code that generates the exception: //1. Add a reference to Microsoft.Office.Interop.Excel (version 11.0.0.0) //2. Compile and run the following code: using Microsoft.Office.Interop.Excel; class Program { static void Main(string[] args) { Application app = new Application(); Workbook workbook = app.Workbooks[1]; Worksheet worksheet = (Worksheet)workbook.Worksheets[1]; Range range = worksheet.get_Range("A1", "A5"); FormatCondition condition = range.FormatConditions.Add( XlFormatConditionType.xlCellValue, XlFormatConditionOperator.xlBetween, 100, 200); } }

    Read the article

  • SQL Server Account will work for SQL Server but fails to ReportServer

    - by Larry
    Setting up SSRS. For Service Account, I set a domain account as the Report Server Service Account. click apply SQL Server Connection Dialog pops up. Need to specify an account with admin privileges. set Credentials Type = SQL Server Account I use sa account (which works, verified many ways with sql server management studio) I fails with the following: System.InvalidOperationException: Cannot start service ReportServer on computer 'DEVDB5'. --- System.ComponentModel.Win32Exception: The service did not start due to a logon failure --- End of inner exception stack trace --- at System.ServiceProcess.ServiceController.Start(String[] args) at System.ServiceProcess.ServiceController.Start() at ReportServicesConfigUI.Panels.WindowsServiceIdentityPanel.StartWindowsServicePostChangeWindowsServiceIdentity(ServiceController rsService) What am I doing wrong. btw: it was working fine as of yesterday. I originally set up SSRS a few days ago using the sa account

    Read the article

  • Java - short and casting

    - by chr1s
    Hi all, I have the following code snippet. public static void main(String[] args) { short a = 4; short b = 5; short c = 5 + 4; short d = a; short e = a + b; // does not compile (expression treated as int) short z = 32767; short z_ = 32768; // does not compile (out of range) test(a); test(7); // does not compile (not applicable for arg int) } public static void test(short x) { } Is the following summary correct (with regard to only the example above using short)? direct initializations without casting is only possible using literals or single variables (as long as the value is in the range of the declared type) if the rhs of an assignment deals with expressions using variables, casting is necessary But why exactly do I need to cast the argument of the second method call taking into account the previous summary?

    Read the article

  • java palindrome help

    - by jdbeverly87
    I'm creating a program that checks if a word or phrase is a palindrome. I have the actual "palindrome tester" figured out. What I'm stuck with is where and what to place in my code to have the console read out "Enter palindrome..." and then text. I've tried with IO but it doesnt work out right. Also, how do I create a loop to keep going? This code only allows one at a time `public class Palindrome { public static void main(String args[]) { String s=""; int i; int n=s.length(); String str=""; for(i=n-1;i>=0;i--) str=str+s.charAt(i); if(str.equals(s)) System.out.println(s+ " is a palindrome"); else System.out.println(s+ " is not a palindrome"); } }

    Read the article

  • lwjgl 101: How can I write the basics?

    - by Vuntic
    This ought to be really simple, but I cannot for the life of me figure out how to compile anything with lwjgl and have it work. I can write something like package gwison; import org.lwjgl.Sys; public class G { public static void main(String[] args) { System.out.println(Sys.getTime()); } } and I can easily compile a program with several classes in different packages, as long as I wrote all the classes myself. But I have no clue how to make G work. I think it has something to do with classpathes? Maybe? Help?

    Read the article

  • SignalR: hub invokation request

    - by Yuriy Pogrebnyak
    I'm writing custom SignalR client and I need to implement hub invokation. As I understood from .NET client code, I need to send post request to the following url (after establishing connection with server): http://serverurl/signalr/send?transport=serverSentEvents&connectionId=<my_connection_id> . In request body I need to send json string containing basic information about the invoked method. My question is how should this json look like? I'm trying to send smth like this (again, judging by .NET client code): {"data" : {"Hub" : "hubname", "Method" : "methodname", "Args" : {"message" : "msg"} } } But I get the following error: System.ArgumentNullException: Value cannot be null. Parameter name: s. What am I doing wrong? What are required parameters of sending json and how should it be formatted?

    Read the article

  • How to Access a static method in c#?

    - by Surya sasidhar
    in C# oops when we have a static method in a class it access only static members right and the static method can access only with class name am i right. Then i am not able to access the static method in my example can u help me. this is my code..... class myclass { int i ; static int j ; static void get() { j = 101; Console.WriteLine(j.ToString ()); } public void test() { i = 11; j = 12; Console.WriteLine(i.ToString()); Console.WriteLine(j.ToString()); } } class Program { static void Main(string[] args) { myclass clsmyclas = new myclass(); clsmyclas.test(); Console.ReadLine(); } } } when i am trying to access the static method like "myclass.get()" i am not getting the static method

    Read the article

  • Having a little trouble with this Java code. Beginner probably mixing some things with C#.

    - by Sergio Tapia
    package practico1; /** * Programador: Sergio Tapia Gutierrez * Fecha: Lunes 10, Mayo - 2010 * Practico: 1 */ public class Main { public static void main(String[] args) { System.out.println("Esta es una pequena aplicacion para mostrar los"); System.out.println("distintos tipos de datos que existen en Java 6."); //boolean, char, byte, short, int, long, float, double, String ejemplosBoolean(); } public void ejemplosBoolean(){ } } So, I'm just testing some things out, but I'm getting an error claiming that I'm trying to run ejemplosBoolean() in a static context when it isn't a static method. My question is, in Java do methods have to have static in order to use them even if they are in the same class?

    Read the article

  • Using HTMLAgility Pack to Extract Links

    - by Soham
    Hi Folks, Consider this simplest piece of code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using HtmlAgilityPack; namespace WebScraper { class Program { static void Main(string[] args) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml("http://www.google.com"); foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]")) { } } } } This effectively doesnt do anything at all, and is copied/inspired from various other StackOverflow questions like this. When compiling this, there is a runtime error which says "Object reference not set to an instance of an object." highlighting the foreach line. I can't understand, why the environment has become irritable to this humble,innocent and useless piece of code. I would also like to know, does HTMLAgilityPack accept HTML classes as nodes?

    Read the article

  • how to see my managed objects on the stack?

    - by smwikipedia
    I use SOS.dll in VisualStudio to debug my C# program. The program is as below. The debug command is !DumpStackObjects. class Program { static void Main() { Int32 result = f(1); } static Int32 f(Int32 i) { Int32 j = i + 1; return j; <===========BreakPoint is here } } After I input the "!dso" command in the immediate window of Visual Studio, the result is as below: OS Thread Id: 0xf6c (3948) ESP/REG Object Name Why there's nothing? I thought there should be the args i and local variable j. Thanks for my answering my naive questions...

    Read the article

  • Why is the user.dir system property working in Java?

    - by Geo
    Almost every article I read told me that you can't have chdir in Java. The accepted answer to this question says you can't do it in Java. However, here's some of the stuff I tried : geo@codebox:~$ java -version java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing) Here's a test class I'm using : import java.io.*; public class Ch { public static void main(String[] args) { System.out.println(new File(".").getAbsolutePath()); System.setProperty("user.dir","/media"); System.out.println(new File(".").getAbsolutePath()); } } geo@codebox:~$ pwd /home/geo geo@codebox:~$ java Ch /home/geo/. /media/. Please explain why this worked. Can I use this from now on and expect it to work the same way on all platforms?

    Read the article

  • How cancel shutdown from a windows service C#

    - by scrat789
    Hello everybody I have a windows service started (written in C# .net2.0). I want to detect when the computer shutdown/reboot and cancel it. After the cancel I want do some actions and restart windows. I have tried it, but it not working using Microsoft.Win32; partial class MyService: ServiceBase { protected override void OnStart(string[] args) { SystemEvents.SessionEnding += new SessionEndingEventHandler(OnSessionEnding); } private void OnSessionEnding(object sender, SessionEndingEventArgs e) { e.Cancel = true; //Do some work... } } Another test: partial class MyService: ServiceBase { protected override void OnShutdown() { //Do some work... //base.OnShutdown(); } }

    Read the article

  • using WP_Query with custom SQL in wordpress

    - by Matt Facer
    Hi. I am writing a plugin for wordpress and I want to create my own search. I have tried to alter the wordpress search, but what I am doing is very specific with the SQL query. I am comparing lat and long coordinates and getting posts based on that. I can display posts by using the standard wpdb query, but then I don't get the other features like paging. I'd like to be able to use my SQL statement with the WP_Query function. If I'm right in thinking, I should then be able to use the paging and other features which come from the $posts global variable. Is this right?? I've googled for hours but can't find anything for plugins outside of using args to select categories etc. I simply need to send a complete SQL command - nothing else. Many thanks....

    Read the article

  • Reading inputs in java

    - by Gandalf StormCrow
    Hello everyone I'm trying to improve my Java skills by solving some problems from ACM, now the thing is my sample input looks like this : 3 100 34 100 75 250 27 2147483647 101 304 101 303 -1 -1 So at first I'm just trying to read them but its not working here is the java code: import java.io.BufferedInputStream; import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner stdin = new Scanner(new BufferedInputStream(System.in)); while (stdin.hasNext()) { System.out.println(stdin.nextInt() + " and the next " + stdin.nextInt()); } } } I'm trying to send these inputs as an argument, and not by reading them from file, here is how: The program just spins(executes) but not printing anything. How can I fix this?

    Read the article

  • Web Service Client Java

    - by zeckk
    I generated java web service client from here -- http://api.search.live.net/search.wsdl.. I want to make search and listing the return values. How i can show result ? my code is : import java.rmi.RemoteException; import com.microsoft.schemas.LiveSearch._2008._03.Search.*; public class searchtry { public static void main(String[] args) throws RemoteException { LiveSearchPortTypeProxy client=new LiveSearchPortTypeProxy(); SearchRequest request=new SearchRequest(); SearchRequestType1 type1=new SearchRequestType1(); sorgu.setAppId("*****************"); //Windows Live gave this id for using that service sorgu.setSources(new SourceType[]{SourceType.Web}); sorgu.setQuery("Java"); aratip.setParameters(request); SearchResponseType0 answer= client.search(type1); System.out.println(answer.toString()); }

    Read the article

  • "detached entity passed to persist error" with JPA/EJB code

    - by zengr
    I am trying to run this basic JPA/EJB code: public static void main(String[] args){ UserBean user = new UserBean(); user.setId(1); user.setUserName("name1"); user.setPassword("passwd1"); em.persist(user); } I get this error: javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.JPA.Database Any ideas? I search on the internet and the reason I found was: This was caused by how you created the objects, i.e. If you set the ID property explicitly. Removing ID assignment fixed it. But I didn't get it, what will I have to modify to get the code working?

    Read the article

  • SCJP question: Method ambiguous

    - by Markos Fragkakis
    Take a look at this code: public class Test { public static void main(String... args) { flipFlop("hello", new Integer(4), 2004); // flipFlop("hello", 10, 2004); // this works! } private static void flipFlop(String str, int i, Integer iRef) { System.out.println(str + " (String, int, Integer)"); } private static void flipFlop(String str, int i, int j) { System.out.println(str + " (String, int, int)"); } } The compiler gives an error that the invocation is ambiguous: Description Resource Path Location Type The method flipFlop(String, int, Integer) is ambiguous for the type Test Test.java scjp19 - inheritence/src line 3 Java Problem But if the commented-out line is used ti invoke flip-flop, the method is unambiguously invoked (the second one, because autoboxing comes after using the primitive itself). I would expect the compiler to see that the second argument will be unboxed one way or the other, and judge what method must be invoked depending on the third argument. Why does not this happen? What is the rationale?

    Read the article

  • java Finalize method call

    - by Rajesh Kumar J
    The following is my Class code import java.net.*; import java.util.*; import java.sql.*; import org.apache.log4j.*; class Database { private Connection conn; private org.apache.log4j.Logger log ; private static Database dd=new Database(); private Database(){ try{ log= Logger.getLogger(Database.class); Class.forName("com.mysql.jdbc.Driver"); conn=DriverManager.getConnection("jdbc:mysql://localhost/bc","root","root"); conn.setReadOnly(false); conn.setAutoCommit(false); log.info("Datbase created"); /*Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn=DriverManager.getConnection("jdbc:odbc:rmldsn"); conn.setReadOnly(false); conn.setAutoCommit(false);*/ } catch(Exception e){ log.info("Cant Create Connection"); } } public static Database getDatabase(){ return dd; } public Connection getConnection(){ return conn; } @Override protected void finalize()throws Throwable { try{ conn.close(); Runtime.getRuntime().gc(); log.info("Database Close"); } catch(Exception e){ log.info("Cannot be closed Database"); } finally{ super.finalize(); } } } This can able to Initialize Database Object only through getDatabase() method. The below is the program which uses the single Database connection for the 4 threads. public class Main extends Thread { public static int c=0; public static int start,end; private int lstart,lend; public static Connection conn; public static Database dbase; public Statement stmt,stmtEXE; public ResultSet rst; /** * @param args the command line arguments */ static{ dbase=Database.getDatabase(); conn=dbase.getConnection(); } Main(String s){ super(s); try{ stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); start=end; lstart=start; end=end+5; lend=end; System.out.println("Start -" +lstart +" End-"+lend); } catch(Exception e){ e.printStackTrace(); } } @Override public void run(){ try{ URL url=new URL("http://localhost:8084/TestWeb/"); rst=stmt.executeQuery("SELECT * FROM bc.cdr_calltimestamp limit "+lstart+","+lend); while(rst.next()){ try{ rst.updateInt(2, 1); rst.updateRow(); conn.commit(); HttpURLConnection httpconn=(HttpURLConnection) url.openConnection(); httpconn.setDoInput(true); httpconn.setDoOutput(true); httpconn.setRequestProperty("Content-Type", "text/xml"); //httpconn.connect(); String reqstring="<?xml version=\"1.0\" encoding=\"US-ASCII\"?>"+ "<message><sms type=\"mt\"><destination messageid=\"PS0\"><address><number" + "type=\"international\">"+ rst.getString(1) +"</number></address></destination><source><address>" + "<number type=\"unknown\"/></address></source><rsr type=\"success_failure\"/><ud" + "type=\"text\">Hello World</ud></sms></message>"; httpconn.getOutputStream().write(reqstring.getBytes(), 0, reqstring.length()); byte b[]=new byte[httpconn.getInputStream().available()]; //System.out.println(httpconn.getContentType()); httpconn.getInputStream().read(b); System.out.println(Thread.currentThread().getName()+new String(" Request"+rst.getString(1))); //System.out.println(new String(b)); httpconn.disconnect(); Thread.sleep(100); } catch(Exception e){ e.printStackTrace(); } } System.out.println(Thread.currentThread().getName()+" "+new java.util.Date()); } catch(Exception e){ e.printStackTrace(); } } public static void main(String[] args) throws Exception{ System.out.println(new java.util.Date()); System.out.println("Memory-before "+Runtime.getRuntime().freeMemory()); Thread t1=new Main("T1-"); Thread t2=new Main("T2-"); Thread t3=new Main("T3-"); Thread t4=new Main("T4-"); t1.start(); t2.start(); t3.start(); t4.start(); System.out.println("Memory-after "+Runtime.getRuntime().freeMemory()); } } I need to Close the connection after all the threads gets executed. Is there any good idea to do so. Kindly help me out in getting this work.

    Read the article

  • noClassDefFoundError using Scala Plugin for Eclipse

    - by Jacob Lyles
    I successfully implemented and ran several Scala tutorials in Eclipse using the Scala plugin. Then suddenly I tried to compile and run an example, and this error came up: Exception in thread "main" java.lang.NoClassDefFoundError: hello/HelloWorld Caused by: java.lang.ClassNotFoundException: hello.HelloWorld at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:315) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330) at java.lang.ClassLoader.loadClass(ClassLoader.java:250) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398) After this point I could no longer run any Scala programs in Eclipse. I tried cleaning and rebuilding my project, closing and reopening my project, and closing and reopening Eclipse. Eclipse version number 3.5.2 and Scala plugin 2.8.0 Here is the original code: package hello object HelloWorld { def main(args: Array[String]){ println("hello world") } }

    Read the article

  • Embedding swank-clojure in java program

    - by user237417
    Based on the Embedding section of http://github.com/technomancy/swank-clojure, I'm using the following to test it out. Is there a better way to do this that doesn't use Compiler? Is there a way to programmatically stop swank? It seems start-repl takes control of the thread. What would be a good way to spawn off another thread for it and be able to kill that thread programatically. import clojure.lang.Compiler; import java.io.StringReader; public class Embed { public static void main(String[] args) throws Exception { final String startSwankScript = "(ns my-app\n" + " (:use [swank.swank :as swank]))\n" + "(swank/start-repl) "; Compiler.load(new StringReader(startSwankScript)); } } Any help much appreciated, hhh

    Read the article

  • Rails & ActiveRecord: Appending methods to models that inherit from ActiveRecord::Base

    - by PlankTon
    I have a standard ActiveRecord model with the following: class MyModel < ActiveRecord::Base custom_method :first_field, :second_field end At the moment, that custom_method is picked up by a module sent to ActiveRecord::Base. The functionality basically works, but of course, it attaches itself to every model class, not just MyModel. So if I have MyModel and MyOtherModel in the same action, it'll assume MyOtherModel has custom_method :first_field, :second_field as well. So, my question is: How do I attach a method (eg: def custom_method(*args)) to every class that inherits from ActiveRecord::Base, but not by attaching it to ActiveRecord::Base itself? Any ideas appreciated.

    Read the article

  • Why I am not able to display image using swing worker?

    - by Vimal Basdeo
    I was trying some codes to implement a scheduled task and came up with these codes . import java.util.*; class Task extends TimerTask { int count = 1; // run is a abstract method that defines task performed at scheduled time. public void run() { System.out.println(count+" : Mahendra Singh"); count++; } } class TaskScheduling { public static void main(String[] args) { Timer timer = new Timer(); // Schedule to run after every 3 second(3000 millisecond) timer.schedule( new Task(), 3000); } } My output : 1 : Mahendra Singh I expected the compiler to print a series of Mahendra Singh at periodic interval of 3 s but despite waiting for around 15 minutes, I get only one output...How do I solve this out?

    Read the article

  • Java: how to register a listener that listen to a JFrame movement

    - by cocotwo
    How can you track the movement of a JFrame itself? I'd like to register a listener that would be called back every single time JFrame.getLocation() is going to return a new value. Here's a skeleton that compiles and runs, what kind of listener should I add so that I can track every JFrame movement on screen? import javax.swing.*; public class SO { public static void main( String[] args ) throws Exception { SwingUtilities.invokeAndWait( new Runnable() { public void run() { final JFrame jf = new JFrame(); final JPanel jp = new JPanel(); final JLabel jl = new JLabel(); updateText( jf, jl ); jp.add( jl ); jf.add( jp ); jf.pack(); jf.setVisible( true ); } } ); } private static void updateText( final JFrame jf, final JLabel jl ) { jl.setText( "JFrame is located at: " + jf.getLocation() ); jl.repaint(); } }

    Read the article

  • Email Verification plugin for rails?

    - by Larry K
    Hi, I'd like to verify a user's email address by sending them a verify-email-message. Do you know of a good Rails plugin that they've used or seen? Since I didn't see anything good via Google, at this point, my thought is: Add a verified boolean field to the user model. Default false. After user is added (unverified), combine email with a salt (a secret), and create the sha1 hash of the email/salt combo. The result is the verification. Send a welcoming / verification email to the user. Email includes a url that has the email address and verification as GET args to a verify action on my server. The verify action recomputes the verification using the supplied email and checks that the new verification matches the one in the url. If it does, then the User rec for the email is marked 'verified' Also will provide action to re-send the verification email. Any comments on the above? Thanks, Larry

    Read the article

< Previous Page | 59 60 61 62 63 64 65 66 67 68 69 70  | Next Page >