473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

An object reference is required for the nonstatic field, method, or property

I am getting the following error on "rec "

rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 * 10);

public int SendCommandFile(string theCommand, int timeOut)
{
rc1 = RoboFTPSession.RoboSendCommand(theCommand, timeOut * 10);
finderror(rc1);
return rc1;
}

Jan 30 '06 #1
5 118832
Make the method static or create an instance of the class before calling the
method. Just like the error indicates.

<df********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I am getting the following error on "rec "

rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 * 10);

public int SendCommandFile(string theCommand, int timeOut)
{
rc1 = RoboFTPSession.RoboSendCommand(theCommand, timeOut * 10);
finderror(rc1);
return rc1;
}

Jan 30 '06 #2
Because SendCommandFile is an instance method, you can't call it using
the class name. You have to make a particular instance of TheFile1 and
then call the method on that instance.

TheFile1 myFile = new TheFile1(... whatever arguments are required
....);
rec = myFile.SendCommandFile("RCVFILE " + TheArrayVal, 10000000 * 10);

Jan 30 '06 #3
I do. here is the code.....
static void Main(string[] args)
{
try
{
Utilities TheFile1 = new Utilities();
TheFile1.StartSession("xxx-FTP", 1, 0, "");
TheFile1.SendCommand("FTPLOGON \"ftp.xxxxxx.com\" /user=xxxx
/pw=xx", 10 * 10);
TheFile1.SendCommand("CD \"C:\\files\\listing\"", 100 * 10);
TheFile1.SendCommand("FTPCD \"test\"", 100 * 10);
TheFile1.SendCommand("FTPLIST \"listing of new_dir.txt\" \"*.*\"",
1000 * 10);
TheFile1.parseFile("C:/files/listing/listing of new_dir.txt");

ArrayList TheArray = TheFile1.FileNameArray;
//string TheArray = TheFile1.FileNameArray.ToString();
for(int i = 0; i< TheArray.Count; i++)
{
rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 *
10);
}
// TheFile1.SendCommand("RCVFILE \"*.*\" /delete", 10000000 * 10);
TheFile1.SendCommand("RCVFILE \"*.*\"", 10000000 * 10);
TheFile1.SendCommand("STOP", 10 * 10);
TheFile1.SendCommand("FTPLOGOFF", 10 * 10);
TheFile1.EndSession();

TheFile1.viewFileNames();
}
catch(Exception)
{

}
}

Jan 30 '06 #4
Hi,

rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 *
10);

where is rec declared?
What about TheArrayVal ?

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 30 '06 #5
On Mon, 30 Jan 2006 14:59:51 -0500, "Ignacio Machin \( .NET/ C# MVP
\)" <ignacio.machin AT dot.state.fl.us> wrote:
Hi,

rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 *
10);

where is rec declared?
What about TheArrayVal ?


I'll bet it's declared in the class that main is declared in. That's
a classic console app error meaning he didn't declare rec as

private static SomeObject rec;

How do I know this? I screw up and do it all the time.
;o)
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Jan 31 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DC | last post by:
I have created the following abstract class: public abstract class BaseC { protected int _ID; protected string _name; protected abstract DataTable GetData(int ID); // intended to hit data...
1
by: TdJ | last post by:
No end of reading on the net and I can not get this to compile! The error message is: An object reference is required for the nonstatic field, method, or property...
5
by: Vicky via DotNetMonster.com | last post by:
Hi, I need help with "An object reference is required for the nonstatic field, method, or property 'dataReader.Class1.data'" Before I put folowing variable in class level, it works fine....
1
by: Bucko | last post by:
Hi guys, this may be an easy for someone... I have a situation like below. The "str" string variable (and any other variable that VS.net declares normally in this space) can be used fine in...
2
by: Beffmans | last post by:
Hi When I run this code: using System; namespace DelegateProject { public delegate void MyDelegate(string s);
2
by: simonZ | last post by:
I have class, which returns dataTable to populate my list box on some other pages: public class dataClass { private Int16 _lvlRights=1 public static DataTable dtAdv() {
2
by: Mike | last post by:
ASP.NET 2.0 I have some code working in a code-behind that I want to move to a utility class. In the code behind, I can reference the querystring and get the Page value easily. However, when...
1
by: =?Utf-8?B?QUEyZTcyRQ==?= | last post by:
I am getting the above error with this Class Library code: namespace ClassLibrary1 { public class Class1 { private string FoundPathKey; public string LastError { get { return FoundPathKey; }
2
by: rameshonweb | last post by:
Iam getting the error an object reference is required for the nonstatic field method or property 'System.Windows.Forms.Control.CreateGraphics()' for this part of code public static void...
4
by: cppquester | last post by:
I have a data set MMSDataAccess with: public partial class MMSDataSet : System.Data.DataSet { ... private TB_ACTHEATDATADataTable tableTB_ACTHEATDATA; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.