How do i compile 2 C# source files together on win7

Posted 03 June 2010 - 11:02 AM

Hi everyone or anyone http://http.cdnlayer...ult/biggrin.gif whenever i try compiln a program dt has 2 source files, a class dt has all other the methods and d 2nd class dt houses d main method what i get is ds error

GradeBookTest.cs(7,3): error CS0246: The type or namespace name 'GradeBook' could not be found (are you missing a using directive or an assembly reference?)
GradeBookTest.cs(7,25): error CS0246: The type or namespace name 'GradeBook' could not be found (are you missing a using directive or an assembly reference?)

Re: How do i compile 2 C# source files together on win7

Posted 03 June 2010 - 11:31 AM

Quote

Hi everyone or anyone http://http.cdnlayer...ult/biggrin.gif whenever i try compiln a program dt has 2 source files, a class dt has all other the methods and d 2nd class dt houses d main method what i get is ds error

It took a little while to translate your question. I hope this helps other readers:

Quote

Hi everyone. Whenever i try compiling a program that has 2 source files, a class that has all other the methods and a 2nd class that houses the main method what i get is this error.

The files being in the same folder isn't magical. Are they using the same namespace.

Re: How do i compile 2 C# source files together on win7

Posted 07 June 2010 - 10:17 AM

Are you writting these files in Visual Studio... or Notepad?
They have none of the typical content that is added automatically by Visual Studio.
If you make a project, then add a class (like your GradeBook) it should have automatically created the namespace for you, as well as the right Using statements.

I think you need to start from scratch on a new project. If you have code from other sources, then add it to files that you create through Visual Studio so all the right pre-requites are added for you. Then you can paste your other code into the file; using it like a template.

You may also do a lot better if you follow some of the "My First Program" books and samples out there. Just to get your feet wet and gain some understanding of how the namespaces and classes relate to each other. *THEN* start the more complex tasks of combining several unrelated sources together.

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5
is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

Re: How do i compile 2 C# source files together on win7

Posted 08 June 2010 - 08:05 AM

If you have VS08 why are you writing code in Notepad.
You're just making life hard on yourself.
As recommended earlier... write your code in VS08 and let it do its job of stubbing out code files for you.

Re: How do i compile 2 C# source files together on win7

That's not a Visual Studio limitation. That's the case for writing a program. Period. It doesn't matter what compiler you use, your program can only have one Main method.

tlhIn'toq:

Quote

You may also do a lot better if you follow some of the "My First Program" books and samples out there. Just to get your feet wet and gain some understanding of how the namespaces and classes relate to each other. *THEN* start the more complex tasks of combining several unrelated sources together.

Re: How do i compile 2 C# source files together on win7

Posted 08 June 2010 - 09:03 AM

First you say you have two main methods. Then you say you have one. First you say you are using Visual Studio, then you say you want to compile using command line.

I'm going to bow out of this conversation now with one last repeat of my earlier advice. Build the project in Visual Studio. Just Visual Studio. Add your new classes inside the new project. If you have code from elsewhere then copy/paste *just the methods* into the classes you made within Visual Studio because you know those classes were made correctly and have all the pre-requisites you need.

You will never be able to take one complete project with its own main() and a totally separate project with its own main() and just magically merge them together and have them work.