473,769 Members | 5,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function to Command line executable getting errors.. PLeasse help ASAP.

5 New Member
Hi,

I had a function to compare two XML files within a project . Now I need to change that into a commandline exe in such a way that it whouls accept two params from the Command line. I have changed it .. but I am getting some errorr

ValidatorUpg.Va lidatorUpg.Comp areXMLFiles(str ing, string, System.Xml.XmlD ocument, System.Xml.XmlD ocument)' cannot be accessed with an instance reference; qualify it with a type name instead

Error 10 Cannot create an instance of the static ValidatorUpg.cs
Error 9 Cannot declare variable of static type ValidatorUpg.cs


Expand|Select|Wrap|Line Numbers
  1. namespace ValidatorUpg
  2. {
  3.     static class ValidatorUpg
  4.  
  5.     {        
  6.         static void Main(string[] args)
  7.         {
  8.             if (args.Length == 0)
  9.             {
  10.  
  11.                 return;               
  12.             }
  13.             else
  14.             {
  15.                 ValidatorUpg upgrade = new ValidatorUpg();
  16.                  Console.WriteLine("Hai");
  17.                    string oFileName = args[0];
  18.                 string fFileName = args[1];
  19.                 //XmlDocument Source;
  20.                 //   XmlDocument Target;
  21.                 XmlDocument Source = new XmlDocument();
  22.                 XmlDocument Target = new XmlDocument();
  23.                 Source.Load(oFileName);
  24.                 Target.Load(fFileName);
  25.                 string rootSource = Source.FirstChild.Name.ToString();
  26.                 upgrade.CompareXMLFiles(args[0],args[1],Source,Target);
  27.  
  28.             }
  29.         }
  30.  
  31.             public static void CompareXMLFiles(string oFileName,string fFileName,XmlDocument Source,XmlDocument Target)
  32.             {
  33.                 foreach (XmlNode ChNode1 in Source.FirstChild.ChildNodes)
  34.                 {
  35.                     //use below if codition if u need to check the sub nodes 
  36.                     if (ChNode1.HasChildNodes == true)
  37.                     {
  38.                         foreach (XmlNode ChNode in ChNode1.ChildNodes)
  39.                         {
  40.                             //CreatePath(ChNode);
  41.                             CompareLower(ChNode, oFileName, fFileName, Target);
  42.                         }
  43.                     }
  44.                     CompareLower(ChNode1, oFileName, fFileName, Target);
  45.                 }
  46.             }
  47.  
  48.         public static void CompareLower(XmlNode NodeName, string oFileName, string fFileName, XmlDocument Target)
  49.         {
  50.             Boolean flag = false;  // node is there 
  51.             string Path = CreatePath(NodeName);
  52.             XmlNodeList selectnodeslist = Target.SelectNodes(Path);
  53.             if (selectnodeslist.Count == 0)
  54.             {
  55.                 insertNode(NodeName, fFileName, Target);
  56.             }
  57.             else
  58.             {
  59.                 foreach (XmlNode selectnode in selectnodeslist)
  60.                 {
  61.  
  62. ----------------
  63. -------------
  64.                                                             if (flag == false)
  65.                 {
  66.                     insertNode(NodeName, fFileName, Target);
  67.  
  68.  
  69. -------------------
  70. ---------------------
  71.                 }
  72.             }
  73.         }
  74.         public static void insertNode(XmlNode Node, string fFile,XmlDocument Target)
  75.         {
  76. -------------            
  77.         }
  78.         public static string CreatePath(XmlNode Node)
  79.         {
  80. -----------
  81.          }
  82.     }
  83. }
Nov 17 '08 #1
14 1665
Plater
7,872 Recognized Expert Expert
Well these two are easy.
Error 10 Cannot create an instance of the static ValidatorUpg.cs
Error 9 Cannot declare variable of static type ValidatorUpg.cs
You have static classes and you are trying to instanciate them. Static classes to not get instanciated, which means no constructor references (that would be the myclass a = new myclass() stuff)

The same thing applies to the first error, you are trying to use a static class with an instance when you need to use it as a type
Nov 17 '08 #2
anju458
5 New Member
I am still getting an error ... in the command line ....


I am giving the cmd line as

ValidatorUpg.ex e "Validator_EN_O LD.xml","Valida tor_EN.xml"

I am getting an IndexoutofRange exception .

Please help ASAP.





class ValidatorUpg

{
static void Main(String[] args)
{

Console.WriteLi ne("{0}:{1}", args[0], args[1]);
Console.ReadLin e();
XmlDocument Source = new XmlDocument();
XmlDocument Target = new XmlDocument();
ConfigManager cm = new ConfigManager() ;
string fPath = (cm.DataFileLoc s.BinDirectory. EndsWith("\\")) ? cm.DataFileLocs .BinDirectory : cm.DataFileLocs .BinDirectory + "\\";
string fFileName = Path.Combine(cm .DataFileLocs.B inDirectory, args[1].ToString());
if (File.Exists(fF ileName))
{
string nFileName = (cm.DataFileLoc s.EditDirectory .EndsWith("\\") ) ? cm.DataFileLocs .EditDirectory : cm.DataFileLocs .EditDirectory + "\\";
string oFileName = Path.Combine(cm .DataFileLocs.E ditDirectory, args[0].ToString());
// File.Move(fFile Name, oFileName);
MessageBox.Show (args[0].ToString(), args[1].ToString());

Source.Load(oFi leName);
// This is the point where the new file can be installed on to the Bin Folder
Target.Load(fFi leName);
ValidatorUpg Upgrade = new ValidatorUpg();
ValidatorUpg.Co mpareXMLFiles(o FileName, fFileName, Source, Target);
}
else
{
//CONTINUE WITH INSTALLATI N
}
}


public static void CompareXMLFiles (string oFileName,strin g fFileName,XmlDo cument Source,XmlDocum ent Target)
{
foreach (XmlNode ChNode1 in Source.FirstChi ld.ChildNodes)
{
//use below if codition if u need to check the sub nodes
if (ChNode1.HasChi ldNodes == true)
{
foreach (XmlNode ChNode in ChNode1.ChildNo des)
{
//CreatePath(ChNo de);
CompareLower(Ch Node, oFileName, fFileName, Target);
}
}
CompareLower(Ch Node1, oFileName, fFileName, Target);
}
}

public static void CompareLower(Xm lNode NodeName, string oFileName, string fFileName, XmlDocument Target)
{

}
Nov 17 '08 #3
Plater
7,872 Recognized Expert Expert
Well where is the error occuring?
Have you debugged your application?
Nov 17 '08 #4
balabaster
797 Recognized Expert Contributor
remove the "," from your param list...
Nov 17 '08 #5
anju458
5 New Member
I am getting an error right at the first line
Console.WriteLI ne
Nov 17 '08 #6
balabaster
797 Recognized Expert Contributor
And that's caused because of the "," in your command line... as I stated previously. Remove the "," from your command line so that it reads

ValidatorUpg.ex e "Validator_EN_O LD.xml" "Validator_EN.x ml"

Your application is reading the command line args all in as one string... so it's failing because Args[1] doesn't exist.

Args[0] = "Validator_EN_O LD.xml,Validato r_EN.xml"

Args has a length of 1...

and that's what's causing your problem...
Nov 17 '08 #7
jairam singh
1 New Member

I have a problem In ASP code. While I am using a variable as a table name in ASP with MS Access Database. I did try, but I didn’t get success.

Dim cust_name
cust_name=(any table name)

1. sql2="Insert Into '"&cust_name&"' (credit_balance ,credit_date)VA LUES('"&amount& "','"&date1&"') "
2. sql2="Insert Into '"+cust_name+"' (credit_balance ,credit_date)VA LUES('"&amount& "','"&date1&"') "


( Where cust_name is a variable. It is being used as a Table name. But these quiries are not working. Please any body give me help…… or correct Ans……..
Error: Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause.
/anoop_tyre/cash_insert.asp , line 19
Nov 18 '08 #8
r035198x
13,262 MVP

I have a problem In ASP code. While I am using a variable as a table name in ASP with MS Access Database. I did try, but I didn’t get success.

Dim cust_name
cust_name=(any table name)

1. sql2="Insert Into '"&cust_name&"' (credit_balance ,credit_date)VA LUES('"&amount& "','"&date1&"') "
2. sql2="Insert Into '"+cust_name+"' (credit_balance ,credit_date)VA LUES('"&amount& "','"&date1&"') "


( Where cust_name is a variable. It is being used as a Table name. But these quiries are not working. Please any body give me help…… or correct Ans……..
Error: Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause.
/anoop_tyre/cash_insert.asp , line 19
Start your own thread. Hijacking someone's thread is considered rude.
Nov 18 '08 #9
anju458
5 New Member
Hi ,
I have an exe to which 2 arguments are to be passeed.. where both the arguments are two file paths to xml files which are to be compared.

It works fine when i put the two xml files in teh C:\ and execute but when its changes to any other dir like documents and settinsg etcetce it doesnt work.



ValidatorUpg.ex e C:\Validator_EN _OLD.xml C:\Validator_EN .xml ---- Works fine


But when i change to the path to anything else like
ValidatorUpg.ex e C:\Documents and settings\All users\Validator _EN_OLD.xml C:\Documents and settings\All Users\Validator _EN.xml


its is not working .. and to my surprise its not even entering the loop which runs when the args.Length ==2...

Any suggestions ???
Nov 18 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
4964
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
2
1621
by: Ever Olano | last post by:
Hi. In the docs, it says the command-line executable (that allows you to run PHP scripts on your console as opposed to inside the web server) was introduced in 4.3.0. But I was told by someone that he can do command-line stuff with 4.1.0. Is anyone else using the command-line executable with a version earlier than 4.3.0? Thanks!
4
3158
by: yawnmoth | last post by:
say i have the following two php scripts: ptest.php: <? $p1 = popen("c:\\php\\php -q hello.php","r"); $p2 = popen("c:\\php\\php -q hello.php","r"); while (!feof($p1)) print fgets($p1); while (!feof($p2)) print fgets($p2);
10
3824
by: Mandy | last post by:
I have a command line tool that I would like to run from my .NET web application using System.Diagnostics.ProcessStartInfo. I run cmd.exe with this and then pass the command to run the tool as an argument to the process. When I try this from a Windows application it works fine, however, when I do this from my web application I get errors. Both applications are running under the same users so am not sure if it is a permissions problem. ...
2
7703
by: news | last post by:
I just upgraded to PHP 4.4.2 on my Slackware 10.2 system. And Apache/mySQL/PHP all work great through a browser. No errors. But when I try to run a PHP script through the command line, which I need to do, I get blocks of errors like: root@slackserve:/var/www/htdocs# php ./phptest.php PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php/extensions/mysql.so' - libmysqlclient.so.14: cannot open shared object file: No such...
12
14360
by: bobrics | last post by:
Hi, I have been trying to compile some source code that is supposed to be working and getting some compilation errors. The errors are with sqrt(), log() and round() functions. I have math.h included and made sure it's in the path. I have read on the forums that some have fixed the problem by telling GCC to link math libraries if it's not done by default. So, using gcc -lm helped to resolve the problems with defining the
8
3942
by: Ian Mackenzie | last post by:
Hi Guys I am VERY new to DB2 and have created a workingdays function to return the working days between 2 dates, but I get some compiler errors when running it: CREATE FUNCTION WORKINGDAYS (STARTDATE, ENDDATE DATE) RETURNS INTEGER DETERMINISTIC NO EXTERNAL ACTION BEGIN ATOMIC DECLARE DAYCOUNT INTEGER
1
1448
by: sowmi | last post by:
Hi All, I am trying to implement the concept of function pointer in C++. While compiling i got some errors which I couldnt figure out the reason . So,Please let me know what changes should be done for resolving that error. I am trying to execute one particular command function when the commandis pressed.Likewise, I have 100 commands and whenever the commands are pressed the corresponding function + arguements should be passed and the...
51
4158
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under Command Prompt or Browser or some other application? Ojas.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.