SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Getting started with a simple CS file

Last post 06-20-2017 8:44 PM by sbridewell. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-11-2017 5:21 PM

    • LofaDay
    • Not Ranked
    • Joined on 04-11-2017
    • London
    • Posts 1

    Getting started with a simple CS file

    Hi all, Newby to this -- Installed OK, CS files​ associated with it OK, CS file loads OK, Same CS file compiles with dot net's CSC.exe fine (Net 4). SharpDevelop doesn't want to know. Almost all Build / Debug greyed out. After much consulting the oracle Google, not a sausage. Debug / "Attach to process" seemed a good place to start.  Nope, that just made mscorsvw.exe vanish from list. Came back after about 3 restarts. Finally, I find a feature that is not greyed out - an icon called "Builds all projects in the current solution"-- and that finally says "Compiling single files is not supported. Please create a project". So I go to File / New and Project is GREYED OUT. I can create a new CS file, which does NOTHING. So I choose New Solution. Then I get folders, I get files, I get lost, I give up.

    Anyone telling me I should know how to use C#  before I come here is missding the point. I was fine with C# and Notepad++ and I wanted something a tiny bit better, buit I do not want to download MS.Net (I downloaded there Community edition, and on a 64 bit PC, it took 3 hours, then updated itself for anotgher 3 hours, then .. well, let's just remind ourselves I came here for something simpler and lighter, but something more t6han a text editor. 

    So basically may I ask could we simplify this for newbies? Could you please help with a simple simple simple getting started guide? Please see tags for simplified questions. I hope this query helps others. 
    Ps: Tried to sign in with a *.eu email address, email came 30 mins later. Tried, it took about 15 mins. Ended up ignoring first. That's not good is it. :-) .. Idea: Tell folks to expect to wait 30 mins?
  • 06-20-2017 8:44 PM In reply to

    Re: Getting started with a simple CS file

    If I've read this correctly then you've learned C# by writing your code files in a text editor and compiling them on the command line by passing the names of the .cs files to csc.exe? Yes, that'll work, but it quickly becomes unmanageable as soon as you've got more than a handful of code files.

    So you are correct to investigate using an IDE such as SharpDevelop or Visual Studio (which I guess is what you mean by, and in my personal opinion SharpDevelop will be better for your needs than Visual Studio - as you've observed, the VS 2015 Community edition takes hours to install, and I've also found it to be resource hungry and slow to start up, whereas SharpDevelop starts up in no time and I can run several instances of it at once without it bringing the rest of my PC to a standstill.

    So the first thing you need to know about working in an IDE (SharpDevelop or Visual Studio or almost any other) is that they all revolve around projects and solutions. A solution (.sln file) is the wrapper for all the things you want to work on in one instance of the IDE. A solution contains one or more projects. A project (.csproj file if you're working in C#, there are other filename extensions for other languages) contains all the code files which build into a single assembly (.exe or .dll file). The IDE allows you to build either a single project within the solution or all the projects in the solution, and when you do that, the IDE tells msbuild (a part of the .net SDK) to build that project, and the project file contains all the information that msbuild needs to know how to build it (in the case of a .csproj file it contains all the information to build that csc.exe command line for you), courtesy of the IDE putting all that information into the project file for you, while you concentrate on writing your code.

    A lot of the time, you'll be working with a single instance of whichever IDE you choose to use, on a single solution, which contains all the projects which make up your application (which will initially be only one project, but hopefully you'll soon see the benefits of moving some of your code into a separate class library project).

    So... how to do it. Launch SharpDevelop. You should see a start page with a "new solution" button. This will create a new solution file for you containing one project, you need to choose the type of project. In the folder structure in the left hand pane, navigate to C# -> Windows Applications. In the right hand pane, choose the type of project to create (you probably want "console application" or "windows application", depending on whether you want something to run from the command line or something which displays a graphical UI to the user), give names to the project and solution and click the Create button.

    You now have a solution containing one project, which in turn contains a single class file created by default. You can double-click on this class file in the solution explorer tab to edit it, or you can right-click on it and choose to delete it. You can right-click on the project in the solution explorer tab and either add a new class file to the project, or add an existing file to the project (you'll be prompted to browse for the file you want to add).

    Hopefully by now, you'll have a solution containing a project containing the .cs files that you were previously compiling using the csc.exe command line. Press F5 or click on the green triangle button on the toolbar to build and run your project.

    Before I finish, I'd urge you to right-click on the project in the solution explorer tab and select "properties". This shows you lots of the information that SharpDevelop puts into that .csproj file so that you don't have to. And it also allows you to override SharpDevelop's default decisions about what goes into the project file, e.g. what is the default namespace for this project, do you want to FxCop your code each time it's built, do you want to build a documentation xml file for Sandcastle, do you want to target a particular processor architecture, that sort of thing.

    I'll stop there, I appreciate that you've been waiting over 2 months for a reply and you might not even be watching this post for a reply any more, but if you are reading this and have more questions, please ask away... :-)


Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this ( email address.