Jump to content
  • Advertisement
Sign in to follow this  
Ralphzehunter

C#, odd problem....

This topic is 5017 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is my code: using System; using System.IO; public class Mygame { string[] weaponname = new string[10]; int[] weaponpower = new int[10]; int[] weaponend = new int[10]; int[] weaponcost = new int[10]; public static void Main() { ReadWeapons(); } public static void ReadWeapons() { TextReader tr = new StreamReader("w.dat"); int i = tr.Read(); int x = 0; while (x < i) { weaponname(x) = tr.Read(); weaponpower(x) = tr.Read(); weaponend(x) = tr.Read(); weaponcost(x) = tr.Read(); x++; } } } Done... When I try to compile, this is what it says: c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\mscorlib.dll: error CS0011: Referenced class 'string' has base class or interface '' defined in an assembly that is not referenced. You must add a reference to assebly ''. c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\mscorlib.dll: error CS0011: Referenced class 'int' has base class or interface '' defined in an assembly that is not referenced. You must add a reference to assebly ''. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
This compiles in .NET 2003. I created an empty console app and made some changes to your code. I think some of your environment variables may not be set up correctly.

Under options->projects->VC++ their should be some references to $(framework) directories.

Do you have any sample programs that came with your compiler that do compile correctly?

Also, I don't think the TextReader.Read() method is being used correctly. It only returns the next ascii character from the file.

//==========================================
public class Mygame
{
public static char[] weaponname = new char[10];
public static int[] weaponpower = new int[10];
public static int[] weaponend = new int[10];
public static int[] weaponcost = new int[10];

public static void Main()
{
ReadWeapons();
}

public static void ReadWeapons()
{
TextReader tr = new StreamReader("w.dat");
int i = tr.Read();
int x = 0;
while (x < i)
{
weaponname[x] = (char) tr.Read();
weaponpower[x] = tr.Read();
weaponend[x] = tr.Read();
weaponcost[x] = tr.Read();
x++;
}
}
}
}

Share this post


Link to post
Share on other sites
I would say that it seems like you're missing a reference to system.dll - check under your references, you may have deleted it somehow.

Share this post


Link to post
Share on other sites
thanks for your replies, guys : ).... i dunno what was wrong
my comp got a virus earlier this week that screwed up windows, so i had to format my hd :(.... But now when i compile my code, it works. BTW, thanks about that textreader.read part : )

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!