bizzare VS .NET errors

  • Thread starter Thread starter Sergei Shelukhin
  • Start date Start date
S

Sergei Shelukhin

I am starting to develop for .NET, so I was writing some code at work.

The file was single .cs file I compiled using batch files, and write in
notepad (I don't have VS at work).
It starts like this:


using System;
using System.Xml;
using System.IO;
using System.Windows.Forms;

The app is console-based and consists of 3 classes this far - one is used to
get file system info to xml, the other is used to get tags from mp3 files
and add them to xml, and the 3rd is the one holding main().
Winforms part is used for SaveFileDialog.

Problems started when I tried to work with it using VS at home.
When I open .cs file as is, I cannot run it or compile it, or anything
(why?).
I tried adding it to empty project and VS reported an error telling me
there's no such thing as System.Xml during compilation.
When I tired console project, replacing the code in the initial flev with my
code, VS told me there's no such thing as System.Windows.Forms.

How do I make the simplest piece of code work in VS?
Oh yeah, and it compiles and runs normally when I compile it using batch
files at home, too.
 
The problem is that you haven't set references to the required assemblies.
When you compile using the command line, the C# compiler uses a file called
csc.rsp to find out what default assemblies should be referenced.
Can be found here: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322

When I create an empty project using VS2003, I get a reference to mscorlib
only, this includes System and System.IO. System.Xml and
System.Windows.Forms are located in other assemblies, reference these and
you should be fine.

Chris
 
You can also add parameters to csc to add references. I think it is
/r:<assembly>.

Etienne Boucher
 
Back
Top