FontysICT-sem1

Visual Studio installation

What do I need?

A development environment (IDE for short). If you have no experience yet, we recommend the default:

Default: VS for MS-Windows.

Visual Studio (abbreviated: VS). The default is VS for MS-Windows. In some commands, you see screenshots of WinForms apps (still), which you can create only in this version. In other environments, you must first figure out how to achieve the same effect. Also, a teacher or fellow student may be demonstrating something with WinForms: In that case, it’s easiest if you use the same version.

You can use the Community Edition (free license): everything we do in the starting semester can be done in it.

Alternative: FHICT online workplace.

FHICT also offers an Online FHICT workplace. See studentenplein at portal.fhict.nl.

Alternative: Visual Studio Code.

If you do not have programming experience yet, we do not recommend this, because some things just work differently from your fellow students and teachers: you may have to figure some things out yourself.

And on a Mac?

For both bootcamp and VM solution you need additional software. This can be found for free in the webshop linked above.

Installation

One Way

You search the Internet for "Visual Studio 2017 community". For example, here

They call the free version of VS the Community Edition. When installing, choose ".NET desktop development". This version is sufficient for the starting semester. But….

Another way: Through Student Square

It can also be done through student square on the FHICT portal, under the heading ‘Software’.

Your first program (WinForm, works only in VS for MS-Windows)

Want to know if your VS works? Start up Visual Studio. We will first create a new project and then start typing C# source code. Next, we’ll launch the C# source code. Your first program!

fig:visualstudio

If you this you see after installation, then you are ready to start the next step.

Windows Forms App C#

From the File menu, choose New and then Project. See

New Project. fig:vsprojectnew

Make sure you show the blue part exactly the same as yours on the screen. Keywords: "Visual C#" is selected on the left and it says "Windows Forms App (.NET Framework) Visual C#". Give the project a self-selected name at "Name" and then click "OK".

Tapping C# Sourcecode

To get to the source code of your first (empty) program we need to make it visible. Right click on ‘Form1’ and choose ‘View Code F7’.

You now see C# source code in the middle. Copy the line below and paste it under the line already there. Make it so that your screen looks the same as below. The point is to add just this line. Some of the names in the lines above and below are named a little differently. This is because in the example program the names may have been chosen slightly differently. That’s not a big deal.

MessageBox.Show(System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String("SGVsbG8gV29ybGQh")));

Essentially, then, you just add "MessageBox…"line under the "InitializeComponent()"line. This line contains a secret code that displays a message to you at startup.

Start up first program

After you have typed C# source code, you must instruct Visual Studio to create (compile) and execute (run) the program. You do that with the "Start" button. You will see a message after execution.

You notice that Visual Studio has two "faces". An editing mode and an execution mode.

It’s not working?

Now you may have made a typo in your C# source code. Visual Studio shows that with this screen:

Always choose "No"! Then you can go back to your Visual Studio to see where your typo is.

Typographical errors are indicated by Visual Studio with red circles under the words. Just like in Word. These are sometimes difficult to understand. If so, remove the line and type it again. You can also close the program and revert to a last working version. (Do not save.)

How to proceed?

Try opening the designer from Form1 (right-click on Form1 again, just like opening the code). Drag some buttons (buttons), text (labels), and so on onto your Form1. Adjust the color and text. Make it something pretty! If you double-click a button you can use this code to put down that then becomes visible when you press the button. (Paste this code on the empty line between the { and }.

MessageBox.Show("Thank you for clicking!");