Taking Visual Studio Code and ASP.Net 5 For A Spin

Visual Studio Code Setup

Visual Studio Code Download

https://code.visualstudio.com/Download

Visual Studio Code (VSCode) is the latest free cross platform lightweight IDE from Microsoft. Visual Studio Code and ASP.Net 5 are being released as free and open source.

Initial Impressions for Visual Studio Code

Pros:

  • Lightweight IDE
  • Support for many Languages with IntelliSense
  • Git Integration
  • Open Folder
  • Easy Split Window Navigation
  • User and Workspace settings in JSON

Cons:

  • Does not support regions for C#
  • Keeps hanging when you use on large .Net solutions (Open Folder)

ASP.Net 5 Setup

According to Microsoft, DNX was built entirely from the ground up. The ASP.Net 5 was also created from the ground up, meaning all ASP.Net 5 projects are DNX projects. Good thing to note is that ASP.Net 5 is not anymore based from System.Web.dll. Things are built around the concept of packages and on demand references.

Windows

In order to install and run ASP.Net 5 from Windows, you will need to install the DNVM (Version Manager), DNU (Utility) and DNX (Execution Engine). The steps to install them can be found from this link.

OSX

A very cool new feature of ASP.Net 5 is that it can run and be developed in other platforms. I was very excited to try and develop ASP.Net on a non-Windows machine. It gave me enough reason to buy and upgrade my MacBook Pro 2008 to MacBook Pro 2015 ;).

Just like in Windows, you will need to install the DNX, DNVM and DNU. But this time, since its on OSX, everything will be dependent on Mono (.Net Open Source Project). You can get Mono by installing through Homebrew (package manager) in OSX. Actually, it works backwards, in Homebrew when you install the latest ASP.Net and DNX it installs Mono automatically since its a required package of ASP.Net.

Linux soon!

I do not have now a Linux machine to try and install ASP.Net 5 so next time I will post my ASP.Net 5 adventures with Linux!

Sample Project ASP.NET 5

Omnisharp log – Error logged on opening the sample project

When opening the sample ASP.Net 5 DNX project with VS Code without first installing DNX, you will encounter an error logged under the Omnisharp log. This is a good way to know the sequence where it looks for the DNX framework.

Omnisharp log

The DNX framework can be installed on your system like what I did when I followed the steps to initially setup DNVM, DNU, DNX amongst others. But you can also, make available the different DNX versions in your local by getting and compiling them from the Github repository. This way, you can test different versions of DNX from your system. Running DNVM list will show you different versions installed in your machine.

Two versions of DNX

Running the sample apps

There are sample projects up in the ASP.NET repository. You can download or clone them from Github.

I tried to open and run the web application under the HelloMVC sample folder. This is a sample MVC ASP.NET 5 project which you can open in VSCODE.

Inside the project folder, you can execute

dnu restore

to make download the dependencies of the sample project. Visual Studio Code will also prompt you to do the restore.

DNU Restore VSCode Window

DNU Restore Complete

To execute and start the hosting of the project run the command

 dnx . web 

DNX WEB

Open a browser and go to http://localhost:5001/ and you will see the sample MVC ASP.NET 5 project running.

Sample ASP NET 5 Website running

You can do the same steps to setup, compile and run the web project in OSX. As long as you have DNX installed you can start and run ASP.NET 5 projects. I’m trying to follow the latest in DNX and ASP.NET as a whole in Github – http://www.github.com/aspnet and try to contribute if possible 🙂 Thanks and until my next post!

Snipping Tool Slow Response On New Snip

I recently encountered the snipping tool slow response on new snip on my Windows machine. It is causing which I call COD or “cause of delay” when I’m doing my work and trying to finish on time. What happens is when you capture a screen using the Snipping Tool, your machine just freezes up to 4 to 6 seconds before you can get the new snip and move around with your system. Yes, that is a hassle when all you want is to capture the screen. The Snipping Tool was a reliable tool in Windows until I encountered this issue.

Snipping Tool Slow Response Happens Only With Internet Explorer

I made a search in Google and found that this issue only happens when capturing the Internet Explorer screens. To try this I launched the Snipping Tool and made a new snip. I tried to capture the screen from my Chrome browser, it worked. I tried to capture the screen from my desktop and it worked as well. I went back to capture the screen from my Internet Explorer. Voila, my system instantly froze again!

How To Resolve The Issue on Snipping Tool Slow Response On New Snip

Under Tools, go to Options. The Snipping Tool Options will have an option for “Include URL below snips (HTML only)”. Uncheck that option and then try again to capture your Internet Explorer screen.

Snipping Tool Options

 

You will notice that capturing the screen on your Internet Explorer will now work with normal response and without freezing your system. Hope this helps. If you have other Snipping Tools tip, please share them in the comments section. Thanks! 🙂

Comparing using CompareTo C# Method

 

A colleague asked me for a suggestion on the program module he is doing that involves determining if one value is “>” greater than, “=” equal or “<” less than another value. I first thought of a solution involving a stack but its too low level and involves much longer code. After some suggestions and trying to think of another way, he came across of a solution to use CompareTo C# method.

What is CompareTo C# Method?

First, MSDN defines IComparable as an interface that “Defines a generalized type-specific comparison method that a value type or class implements to order or sort its instances.” It has a method called CompareTo which as defined by MSDN “Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.”

The CompareTo method is available on all objects as long as the objects has the same type. See the sample code below for comparing value types integer and a string type.

CsharpCompareTo

 

The Return Value of CompareTo

The CompareTo method has a return value of int. The integer value return will be one of the values less than 0, 0 or greater than zero as what is shown below.

CompareToReturnValues

 

Nullable Types Does Not Implement CompareTo

Take note that Nullable types like int? short for Nullable<int> does not implement the CompareTo method. It will not even compile since the method is not implemented.

CompareToNullable

This blog post will serve as a quick reference for me whenever there is a need for me to use sorting or comparison of data when programming. I hope it will serve the same for you.

 

 

Changing My DNS Provider to DNSimple – What DNS Record?

 

Problem with my current DNS provider – GoDaddy.com

I made a blog post two years ago on how I setup this site File -> New Blog Project. As of this writing, this site is using WordPress and GoDaddy.com for web hosting and DNS. Lately, I have noticed that sometimes I cannot access my website noelarlante.com and its admin page. Its maybe my internet provider is slow? or my internet is totally down? A quick access to Google proves otherwise.

I did a trace route to noelarlante.com and to my surprise I got timeouts (* * *) on after a certain ip address. My main hosting ip address is working which means the domain name resolution is not working due to the time out.

Traceroute has started…

traceroute to noelarlante.com (203.124.115.1), 64 hops max, 72 byte packets

 1  192.168.11.1 (192.168.11.1)  1.474 ms  1.515 ms  1.011 ms

 2  192.168.254.254 (192.168.254.254)  1.785 ms  1.685 ms  1.584 ms

 3  180.191.75.1 (180.191.75.1)  17.557 ms  17.863 ms  17.545 ms

 4  10.109.9.65 (10.109.9.65)  17.431 ms  21.192 ms  17.735 ms

 5  120.28.0.193 (120.28.0.193)  18.478 ms  23.496 ms  17.978 ms

 6  120.28.10.93 (120.28.10.93)  18.563 ms  21.173 ms  18.075 ms

 7  120.28.4.94 (120.28.4.94)  49.112 ms  52.709 ms  48.848 ms

 8  203.169.57.37 (203.169.57.37)  48.052 ms  48.126 ms  46.980 ms

 9  xe-5-2-0-xcr1.sgs.cw.net (195.2.10.214)  87.515 ms  86.563 ms  86.042 ms

10  ae0-xcr1.sng.cw.net (195.2.10.149)  77.411 ms  78.375 ms  76.861 ms

11  * * *

12  * * *

13  * * *

14  * * *

15  * * *

16  * * *

17  * * *

18  * * *

19  * * *

20  * * *

 

Although I still have two more years with GoDaddy DNS, but I have decided to try and use DNSimple.

Moving My DNS service to DNSimple

DNSimple Support page provides a topic on How Transfer Domain Without a Downtime,  which is the perfect information I need to prevent downtime for my website. Transferring a domain to DNSimple was painless. Its just that I missed a step that ended my site to be down for a day – more on that next.

DNS  DNSimpleDomainAddTransfer

Steps on transferring a domain without a downtime

Here are the steps on how to transfer a domain to DNSimple without a downtime based from the Support page of DNSimple. I’ve highlighted the one step I’ve missed.

After doing the *ALL* the steps I thought that I will just need to wait for the DNS to propagate to all servers and then thats it, transfer done. But after awhile I tried to hit noelarlante.com but I got a “Host Unreachable” error on my browser. Something is wrong and I soon figured that there is a disconnect from my DNS to my hosting server.

Problem Solved – I Missed Adding DNS Records

According to Wiki – DNS records or resource records (RR) is the basic data element in the domain name system.
There are many record types that you can use. DNSimple support has the information about each of them – http://support.dnsimple.com/categories/dns/

 I only care about A, CNAME

A – An A record is an Address. This is the record that maps the address i.e. noelarlante.com to my hosting site

CNAME – CNAME is short for Canonical Name. It is the record that maps an alias to an address. The “www” is considered an alias or an address going to noelarlante.com. If no CNAME with “www” is added to the DNS record, www.noelarlante.com will not be resolved to noelarlante.com.
DNS  DNSimpleAddAliasRecord

DNS  DNSimpleDNSRecords

I got my website a new DNS service provider and so far I’m happy with the response time when I visit my site. This is not in anyway a paid advertisement for DNSimple, I’m just sharing my experience and hope others can find this post and not forget that DNS record step.

 

Notepad++ – Source Code Editor and More

 

Using Notepad++ with Visual Studio

To compliment Visual Studio, I use Notepad++ as my other source code editor. Visual Studio is still my primary IDE but its good to have Notepad++ on the side for that quick search in files, syntax highlighting depending on the language or even when you want to compare texts or codes. There are other free code editors out there like Notepad2 or Sublime but my vote goes to Notepad++.

My Favorite Notepad++ Features

Syntax Highlighting

Notepad++ Syntax Highlighting

You get to choose from the programming languages like C#, C++, SQL, XML to Objective-C or Perl for syntax highlighting.

Find In Files

When I’m working on a big solution file in Visual Studio and I want to look for all references of a specific method, property or keyword I use Notepad++ Find In Files. Instead of waiting for Visual Studio to return to me a list of instances, I just search it with Notepad++. It will take time and it will make Notepad++ unresponsive during search but I can still continue with my coding in Visual Studio.

Notepad++ FindInFiles

 

Plugins

There are number of plugins that are available for install and download. The plugins manager is also a plugin by itself. Just like Package Manager in Visual Studio its the source where third party features can be found.

Notepad++ PluginsManager

 

Useful Plugins

TextFx

Notepad++ TextFxUnwrapText

If you find yourself working on a big chunk of text and its supposed to stay on one line, you can use the “Unwrap Text” option of TextFx. It will remove the newline and carriage return characters of the text to make it a one line.

StraightText

XML Tools

If you are working with XML messages that is sent as a one line of string you can use the “Pretty Print with Line Breaks” option of XML tools. This will arrange the XML nodes with proper indention to make it easier for you to inspect the XML string you have.

Notepad++ XMLToolsPrettyPrint

XMLFormattedText

 

I hope this little note for Notepad++ helps.

Google Chrome Extension Download Not A CRX Error

I’m trying to download a Google Chrome extension in my Windows 8 machine. A simple Pop-up blocker like an AdBlock would be a breeze to install right? No.

Chrome Add Extension

CRX Error

After I received an error “Download was not a CRX” I hit the “Reload” button looking at a simple relaunch is required.

The extension gallery was reloaded but nothing happened, no extension was installed. I tried to do the same steps but got nowhere.

After googling the error, the search pointed me to this blog – http://www.ghacks.net/2012/12/07/fix-chrome-error-download-was-not-a-crx/

Apparently, clearing the cache or manually adding the extension will not work. You need to sign “Sign-in to Chrome” to make it work.

Sign in to Chrome

I tried signing-in into Chrome as suggested and it worked. It worked without even me doing the same steps from downloading the extension in the gallery to clicking the “Add to Chrome” button.

Notice the active AdBlock icon below after signing in.

Signed in to Chrome

Adding an extension in my Chrome from my Mac machine did not require the extra step. Perhaps an extra security for Windows?

Add those extensions now as they may help you to be productive in your tasks. Chrome extensions fire away!

How to Install Hyper-V in Windows 8 Pro and Lenovo W530

Hero hyperv

One of the features included in Windows 8 is the Hyper-V client. In the past, the Hyper-V client is only available from Windows 2008 Server OS now you can have the same feature in Windows 8 Pro. Hyper-V, the machine virtualization technology, lets you run multiple operating systems at the same time on the same machine.

I’ve recently purchased a Lenovo W530 laptop which they called “The Beast”. It has Intel 3rd Gen Core i7 and 16Gigs of RAM(up to 32GB) perfect for Windows 8 Pro and Hyper-V. As a developer, I will need all the resources I can get from this machine.

Enabling Hyper-V Feature

Enabling Hyper-V is simple, just go to Windows 8 features panel to enable. But as you can see below the option for the Hyper-V option is greyed out. Message says “Hyper-V cannot be installed. Virtualization support is disabled in the firmware.

Windows8 Feature  HyperV Disabled withMessage

BIOS Configuration

To fix the issue, you need to go to your BIOS and enable the virtualisation option. For Lenovo W530, below is where you can set Virtualization to “Enabled”.

Lenovo W530 Virtualization BIOS rs

Activating Hyper-V

Go back to Windows 8 features and you now can see that the Hyper-V option is enabled.

Windows8 Feature  HyperV Enabled

Windows will need to restart after enabling the feature.

Windows8 Feature  HyperV Required Restart

After restart, Launch Hyper-V Manager and proceed with creating your virtual machines.

How To Disable Internet Explorer Enhanced Security Configuration on Windows Server 2012 RC

Internet explorer security

This is a guide on how to disable the Internet Explorer Enhanced Security Configuration (IE ESC) in Windows Server 2012 RC. I’ve blogged the steps on how to do this on Windows Server 2008 on my previous post – How To Disable Internet Explorer Enhanced Security Configuration

How to Disable Internet Explorer Enhanced Security Configuration on Windows 2012 RC

When you access a website such as the website of MSDN in Windows Server 2012, you would get the message below:

IE Prompt 2012

To disable this message, go to the Server Manager

ServerManager win2012

On the Server Manager window, choose Local Server, then click the IE Enhanced Security Configuration option under Properties

IE ESC Win2012

You will be then be prompted with the options window below. You can turn off the IE ESC to both Administrators and Users.

IE ESC Disable Win2012

After following these steps, close all Internet Explorer instances and then relaunch. You will now be able to go to websites within your Windows Server 2012 without the IE ESC message.

How To Disable Internet Explorer Enhanced Security Configuration

Internet security RS

This is a guide on how to disable the Internet Explorer Enhanced Security Configuration (IE ESC) which is enabled by default on Windows servers. You would usually disable this security feature on development instances of your Windows Server. The IE ESC feature reduces the risk of attack when you access external websites from within the server as explained by the following message from Microsoft Support:

Microsoft Internet Explorer’s Enhanced Security Configuration is currently enabled on your server. This enhanced level of security reduces the risk of attack from Web-based content that is not secure, but it may also prevent Web sites from displaying correctly and restrict access to network resources.

How to Disable Internet Explorer Enhanced Security Configuration on Windows 2008.

Note: See the steps for Windows Server 2012 RC here – Disable Internet Explorer Enhanced Security Configuration on Windows 2012 RC

When you access a website such as the website of MSDN, you would get the message below:

IE Prompt

To disable this message, go to the Server Manager

ServerManager win2008

On the Server Manager Summary window, click the Configure IE ESC option under Security Information. See exact location below:

IE ESC Win2008

You will be prompted with the options window below. You can turn off the IE ESC to both Administrators and Users.

IE ESC Disable Win2008

After following these steps, close all Internet Explorer instances and then relaunch. You will now be able to go to websites within your Windows server without the IE ESC message.

Build Metro-style Applications – Where to Start?

Build Metro-style Applications – Where to start?

ComeAndGetIt

Microsoft created WinRT(Windows RunTime) API and this will be built-in to the Windows 8 system. Although Windows 8 can still run the Win32 applications we use now, I’d like to believe that majority of the applications will switch to Metro-style soon. If Windows 8 is released today I would use it and I would not want to go back to Win32 setting. There is a big difference on how things work and flow in Windows 8.

Here are some points on how to get your hands on developing Metro-style apps.

Tools you need:

You need Windows 8 Consumer Preview and the Visual Studio 11 Beta to work on developing Metro-style applications. My previous post on Windows 8 installation options can (I hope) help you with setting up your Windows 8 Consumer Preview.

If you think Windows 8 Consumer Preview is not worth your time, you can still take a look and develop Metro-style applications by downloading the Windows 8 SDK and the Microsoft Visual Studio 11 Express Beta. The VS express is free version of Visual Studio created by Microsoft.

The main website for information about developing Metro-style applications is in this website – http://msdn.microsoft.com/en-us/windows/apps

C# Roadmap

Building Metro-style applications does not require that the developer should use C#. In fact, Microsoft made the WinRT API to be compatible with HTML/CSS/Javascript and DirectX/C++. The diagram below was discussed during Build conference last year and I think it would best describe the WinRT compatibility with non-C# development languages.

WinRTApi
WinRT API

I know HTML/CSS/Javascript but I will go with the C# route this time since I almost always use the language on our projects. With using C#, you also need to know about XAML. If you know Silverlight and WPF (Windows Presentation Foundation), the approach is very very similar. You already have the advantage on skills on how everything work on XAML and WPF so less learning curve.

File-New Project-Metro-style

Like other project types, you can create and run a Metro-style application in a few clicks in Visual Studio. File-New Project-Metro-style will show you Metro-style templates you can use with your application.

MetroStyle VS11 NewProject
Visual Studio 11 – Metro Style Templates

You can also check the sample applications (Download Sample Pack) which is available for download. I really like the sample applications since they show the basic features you need to know on developing Metro-style applications and then point you to the exact feature and xaml file involved in the example.

Metro style apps sample gallery
Sample apps gallery

Code52

The Code52 group created the My Finances WinRT Sample Application project and the WPF Metro-Style Scan Application project so developers can contribute and be involved with WinRT and Metro-style application developments. It is recommended to be involved with open-source developments to share and contribute in some way to an ongoing project. Code52 creates a new project every week so the project does not get very complicated for others to be involved and new ideas are fresh every week.

Code52 Projects List
Code52 Project

I believe Windows 8 applications are needed to be developed now and be ready once the Windows 8 is released this year. This is a great time and opportunity for developers to learn and be involved with Metro-style application development. Got it?

by