Search code examples
c#formstypesnamespacescsc

The type or namespace name 'Bussen' could not be found (are you missing a using directive or an assembly reference?)


When i try to compile my source code it gived me this error. When i run the program form visual studio it works. I am currently creating a windows form card game for me and my friends. This is my main Program.cs file.

Error:

Program.cs(16,33): error CS0246: The type or namespace name 'Bussen' could not be found (are you missing a using directive or an assembly reference?)

Code:

using System;
using System.Windows.Forms;
using bussen;

namespace bussen
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Bussen());
        }
    }
}

The other file is called forms1.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using bussen;


namespace bussen
{
    public partial class Bussen : Form
    {

        public List<string> allCards = new List<string> { };
        public List<string> CardsColour = new List<string> { };

        public Bussen()
        {

            FormBorderStyle = FormBorderStyle.None;
            WindowState = FormWindowState.Maximized;
            InitializeComponent();

            LoadCards();
        }

        private void SelectCard(object sender, EventArgs e)
        {
            Random rnd = new Random();
            int RandomNumber = rnd.Next(0, allCards.Count);
            try
            {
                if (CardsColour.IndexOf(allCards[RandomNumber]) < 26)
                {
                    (sender as Button).ForeColor = System.Drawing.Color.Black;
                }
                else
                {
                    (sender as Button).ForeColor = System.Drawing.Color.Red;
                }
                (sender as Button).Text = allCards[RandomNumber];
                allCards.Remove(allCards[RandomNumber]);
            }
            catch
            {
                LoadCards();
            }
        }

        public void LoadCards()
        {
            StreamReader streamreader = new StreamReader(@"cards.txt");
            string line;
            while ((line = streamreader.ReadLine()) != null)
            {
                allCards.Add(line);
                if (CardsColour.Count < 52)
                {
                    CardsColour.Add(line);
                }
            }
            streamreader.Close();
        }

        private void Restart(object sender, EventArgs e)
        {
            Application.Restart();
        }
    }
}

Solution

  • I should have provided more than one file name when compiling -it was [scs "program.cs"] -but is should have been [csc "program.cs" "Form1.cs" "Form1.Designer.cs"]