473,503 Members | 2,150 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.ValidatorUpg.CompareXMLFiles(string, string, System.Xml.XmlDocument, System.Xml.XmlDocument)' 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 1641
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.exe "Validator_EN_OLD.xml","Validator_EN.xml"

I am getting an IndexoutofRange exception .

Please help ASAP.





class ValidatorUpg

{
static void Main(String[] args)
{

Console.WriteLine("{0}:{1}", args[0], args[1]);
Console.ReadLine();
XmlDocument Source = new XmlDocument();
XmlDocument Target = new XmlDocument();
ConfigManager cm = new ConfigManager();
string fPath = (cm.DataFileLocs.BinDirectory.EndsWith("\\")) ? cm.DataFileLocs.BinDirectory : cm.DataFileLocs.BinDirectory + "\\";
string fFileName = Path.Combine(cm.DataFileLocs.BinDirectory, args[1].ToString());
if (File.Exists(fFileName))
{
string nFileName = (cm.DataFileLocs.EditDirectory.EndsWith("\\")) ? cm.DataFileLocs.EditDirectory : cm.DataFileLocs.EditDirectory + "\\";
string oFileName = Path.Combine(cm.DataFileLocs.EditDirectory, args[0].ToString());
// File.Move(fFileName, oFileName);
MessageBox.Show(args[0].ToString(), args[1].ToString());

Source.Load(oFileName);
// This is the point where the new file can be installed on to the Bin Folder
Target.Load(fFileName);
ValidatorUpg Upgrade = new ValidatorUpg();
ValidatorUpg.CompareXMLFiles(oFileName, fFileName, Source, Target);
}
else
{
//CONTINUE WITH INSTALLATI N
}
}


public static void CompareXMLFiles(string oFileName,string fFileName,XmlDocument Source,XmlDocument Target)
{
foreach (XmlNode ChNode1 in Source.FirstChild.ChildNodes)
{
//use below if codition if u need to check the sub nodes
if (ChNode1.HasChildNodes == true)
{
foreach (XmlNode ChNode in ChNode1.ChildNodes)
{
//CreatePath(ChNode);
CompareLower(ChNode, oFileName, fFileName, Target);
}
}
CompareLower(ChNode1, oFileName, fFileName, Target);
}
}

public static void CompareLower(XmlNode 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.WriteLIne
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.exe "Validator_EN_OLD.xml" "Validator_EN.xml"

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_OLD.xml,Validator_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)VALUES( '"&amount&"','"&date1&"')"
2. sql2="Insert Into '"+cust_name+"'(credit_balance,credit_date)VALUES( '"&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)VALUES( '"&amount&"','"&date1&"')"
2. sql2="Insert Into '"+cust_name+"'(credit_balance,credit_date)VALUES( '"&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.exe C:\Validator_EN_OLD.xml C:\Validator_EN.xml ---- Works fine


But when i change to the path to anything else like
ValidatorUpg.exe 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
Curtis Rutland
3,256 Recognized Expert Specialist
Try putting quotes around your paths...spaces can screw up the command line.

Expand|Select|Wrap|Line Numbers
  1. ValidatorUpg.exe "C:\Documents and settings\All users\Validator_EN_OLD.xml" "C:\Documents and settings\All Users\Validator_EN.xml"
Something like that.
Nov 18 '08 #11
anju458
5 New Member
Thanks a lot it works.. but itss really surprising that for the C: it works and for any other it doesnt ....

Thanks
Nov 18 '08 #12
Curtis Rutland
3,256 Recognized Expert Specialist
Notice that in the c:\ you don't have any spaces in the path name.
Nov 18 '08 #13
balabaster
797 Recognized Expert Contributor
This is a double post... and has already been answered...

http://bytes.com/forum/thread854813.html
Nov 18 '08 #14
Curtis Rutland
3,256 Recognized Expert Specialist
I've joined the threads.
Nov 18 '08 #15

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

Similar topics

9
4935
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...
2
1603
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...
4
3149
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...
10
3805
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...
2
7671
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...
12
14320
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...
8
3918
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...
1
1436
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...
51
4081
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...
0
7205
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,...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7008
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...
0
7467
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...
1
5022
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...
0
4688
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...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.