Computing.Net > Forums > Programming > MOOOORE trouble with C#... :(

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

MOOOORE trouble with C#... :(

Reply to Message Icon

Name: El-Trucha
Date: March 25, 2005 at 16:14:08 Pacific
OS: Windows XP SP2
CPU/Ram: 2.8 GHz/448 MB
Comment:

Hello every1!! :D
OK...sorry for asking so much questions, but I couldn't find help elsewhere... :(

Here's the code that's causing problems:

public static string GetEmail()
{
return this.email.Text;
}

public static string GetServer()
{
return server.Text;
}

public static string GetVictim()
{
return victim.Text;
}

It tells me:
C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\Form1.cs(414): Keyword this is not valid in a static property, static method, or static field initializer

C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\Form1.cs(419): The type or namespace name 'server' could not be found (are you missing a using directive or an assembly reference?)

C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\Form1.cs(424): 'SysInfoSender.Form1.victim' denotes a 'field' where a 'class' was expected

C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\MakeFile.cs(17): The type or namespace name 'source' could not be found (are you missing a using directive or an assembly reference?)

C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\MakeFile.cs(17): The type or namespace name 'source' could not be found (are you missing a using directive or an assembly reference?)

Why is it telling me this?? I've tried many things already, such as using "this.email.Text", or "this.InitializeComponent.email.Text" (which I didn't think would work...)
Thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx



Sponsored Link
Ads by Google

Response Number 1
Name: SN
Date: March 25, 2005 at 16:40:06 Pacific
Reply:

First and foremost, a word on nettiquette: I spent a fair amount of time researching & answering your last question, and it's common courtesy to post back and let the person (and future readers) know if the response was helpful, if you found another solution, etc. It's very disappointing when you spend a long time on a question and never hear from the original poster again.

Anyhow, for this question, the keyword 'static' means that the function should be called without an instance of the class...You call it by the classname.functionname. Consider the difference between the following examples:

Math m = new Math();
int x = m.abs(-3);

int x = Math.abs(-3);

Obviously, it makes more sense to put the 'abs' function as a static method, since there's no reason to create an instance of the 'Math' class.

So the problem with your code is that you've declared your methods as static, but you're referring to an instance ('this', in all three cases, although you only explicitly specify it in the first one) in a static method, which doesn't make any sense.

In short, remove the word 'static' from each method declaration and you should be fine.

-SN


0

Response Number 2
Name: El-Trucha
Date: March 25, 2005 at 17:30:20 Pacific
Reply:

I'm VERY VERY sorry for not answering...and u know what?? I've experienced sometimes that I post something, and when I come back, the post is gone...but this time, I didn't answer to the post kuz it didnt even show up on My Computing.Net!! :|
Sorry for not answering, soemthing's really weird around here... :@ :(

But anyways...I removed the static keyword, and it asked me for an object reference, so I made one:


Form1.GetEmail gEmail = new Form1.GetEmail();
Form1.GetEmail gVictim = new Form1.GetVictim();
Form1.GetEmail gServer = new Form1.GetServer();

That gives me a BUNCH of errors, some repeated ones...here's one of each:

C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\Form1.cs(419): The type or namespace name 'server' could not be found (are you missing a using directive or an assembly reference?)

C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\MakeFile.cs(21): 'SysInfoSender.Form1.GetEmail()' denotes a 'method' where a 'class' was expected

C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\MakeFile.cs(22): The name 'gEmail' does not exist in the class or namespace 'SysInfoSender.MakeFile'

C:\Documents and Settings\El-Trucha\My Documents\Visual Studio Projects\SysInfoSender\MakeFile.cs(23): 'SysInfoSender.Form1.GetEmail()' denotes a 'method' where a 'class' was expected

Why is this?? :(

Here's both Form1.cs and MakeFile.cs:
http://www.boredsource.com/eltrucha/files.zip
Thanx!! ;)

And I'll look at the other post...thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Response Number 3
Name: El-Trucha
Date: March 25, 2005 at 17:41:59 Pacific
Reply:

Fixed some stuff and it WORKED now!! :|
Lemme fix some file adding thing...and then I'll tell u if I get more errors...much thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Response Number 4
Name: El-Trucha
Date: March 25, 2005 at 19:07:17 Pacific
Reply:

I fixed almost everything now...thanx!! :D
One last thing...why do I get an exception about CDO.Message when trying to send mail?? look:

MailMessage emailMsg = new MailMessage();
// See MailMessage.SaveMessageToFile method to see
// how to save a whole message to a file
// Load the whole message from emailMsg.eml
emailMsg.Body = "This e-mail address can be used with SysInfoSender. ;)";
// Message properties can be overridden
emailMsg.To = email.Text;
emailMsg.Subject = "Testing...";
SmtpMail.SmtpServer = emailServer.Text;
SmtpMail.Send(emailMsg);
MessageBox.Show("Go check your inbox now. If you got the message, then you can use that email/server with this program. Otherwise, not. Sorry",
"Done...", MessageBoxButtons.OK, MessageBoxIcon.Information);

While searching for a solution, I heard that CDO is not installed on all machines...but...can I override CDO?? I don't even know what it is... :P
Thanx!! ;)
(BTW, I uploaded my most recent code to the server)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Response Number 5
Name: Mechanix2Go
Date: March 25, 2005 at 22:52:50 Pacific
Reply:

El-Trucha,

You may want to try the excellent:

HTML Entity Coder/Decoder

by Dr. Nick, available here:

http://golden-triangle.com/CODEPOST.htm

It will make your code easier to read in the forum.


M2

If at first you don't succeed, you're about average.


0

Related Posts

See More



Response Number 6
Name: El-Trucha
Date: March 26, 2005 at 05:57:41 Pacific
Reply:

MailMessage emailMsg = new MailMessage();    
// See MailMessage.SaveMessageToFile method to see
// how to save a whole message to a file
// Load the whole message from emailMsg.eml
emailMsg.Body = "This e-mail address can be used with SysInfoSender. ;)";
// Message properties can be overridden
emailMsg.To = email.Text;
emailMsg.Subject = "Testing...";
SmtpMail.SmtpServer = emailServer.Text;
SmtpMail.Send(emailMsg);
MessageBox.Show("Go check your inbox now. If you got the message, then you can use that email/server with this program. Otherwise, not. Sorry",
    "Done...", MessageBoxButtons.OK, MessageBoxIcon.Information);

Hmm...I just pasted some other code and the post was wider... :(
But anyways, I used the program u told me, thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Response Number 7
Name: SN
Date: March 28, 2005 at 17:34:37 Pacific
Reply:

Didn't get to look at this until now...Can you post the exact text of the exception you're getting? Several things could be causing this (ISP not allowing routing to other mail servers, CDO not installed correctly, etc.) Maybe the whole exception will provide a clue.

Good luck,
-SN


0

Response Number 8
Name: El-Trucha
Date: March 29, 2005 at 13:41:12 Pacific
Reply:

I get this:

-----
An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll

Additional information: Could not access 'CDO.Message' object.
-----

Now...when trying to use another e-mail program for .NET which I got off CodeProject I think, "mail.bellsouth.net" works, but it doesnt get to my inbox!! :@
What do I do?? :(
Thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: MOOOORE trouble with C#... :(

Trouble with C www.computing.net/answers/programming/trouble-with-c/8091.html

Help with C www.computing.net/answers/programming/help-with-c/10733.html

make folder with C www.computing.net/answers/programming/make-folder-with-c/500.html