473,467 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 118841
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; ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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
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
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.