Saturday, April 07, 2018

Microsoft Visual Studio 2017 Windows Console Application template loading error

Trying to create a C++ Windows Console Application brings up this error. I could create a project without an error two days ago. The only thing that has changed is that there was on OS build upgrade yesterday.

Microsoft Visual Studio Community 2017 Version 15.5.7 on Windows 10 Pro, Version 1803, build 17133.1 installed 4/6/2018

Error details:

Error: this template attempted to load component assembly 'Microsoft.VC.Wizards, Version=15.0.0.0, Culture =Neutral,
PublicKeyToken=b03f5f7f11d50a3a'. For more information on this problem and how to enable this template, please see documentation on Customizing Project Templates.


Well, right now I have no solution. Will post, if I find a solution. In the mean time , you can help by commenting.

The fix is  here.

Monday, April 02, 2018

Creating your first C++ Console Application in Visual Studio 2017 Community

If you do not find the template for Console Application in Visual Studio 2017 Community's New Project window, read this here.

Launch VS 2017 Community and click New Project and expand the Visual C++ and Click Windows Desktop as shown. Provide a name, herein CplusDektop_1 and click OK. The program is saved to the default location (C:\Users\Owner\source\repos)


DTConsole_0.png

When you click OK, the program files/folder will be created as shown in the solution explorer.


DTConsole_1.png

There are two source files, CplusDesktop_1.cpp and stdafx.cpp. The CplusDekstop_1.cpp has the main() program as shown and is the entry point for the application:


DTConsole_2.png


The stdafx.cpp contains the pre-compiled type application and contains the header file stdafx.h. You may add other header file information if you need to, here.


DTConsole_3.png

You get intellisense support as shown and you should be looking forward to it as it increases productivity.


DTConsole_4.png
With the 'std' namespace added, the CPP file appears as shown.


DTConsole_5.png

Let us program  a 'Hello World" example.

You want to display 'Hello World' when the program is run. For getting input or putting out output you need to include the following:
#include <iostream>

With this added, your cpp file is as shown. 


Click Build solution from the main menu. You should see this:


DTConsole_7.png

Go to Debug menu as shown.



Click Start Without Debugging. The program runs and you see Hello World printed to the console as shown.


You do not have C++ Console Application template in Visual Studio 2017 Community, no problem.

There is no need to panic. Visual Studio 2017 Community has a fine-grained installer. It is possible that you missed choosing the required programs. Your New Project looks like this now.


There are no templates in the above window. There is a link, Open Visual Studio UI shown in the above window. Click the link and after a little while, the installer is launched as shown. However, you may encounter this window. Click Update and you may get yet another window asking you to save/close running programs.

Now the installer is launched.


It appears I did not choose to install Desktop development with C++. Place check mark and allow the program to add this and any other that you choose to your VS 2017 Community.

After the changes the VS 2017 is relaunched and now you find many more C++ related templates in your New Project windows as shown.


The modification also adds these programs to your Visual Studio 2017 Community:

Microsoft Vsiual C++ 2017
Microsoft Visual C++ Wizards -1.0

Regular Expressions with C# Interactive

Yes, you can. However you have to reference the Regex class (System.Text.RegularExpressions) as shown in this image.


After this you can use its objects and you have intellisense to provide you help in coding.


The Syntax for using RegularExpressions is:

Match match = Regex.Match(InputStr, Pattern, RegexOptions)

You set up a pattern and you test your Pattern against the InputStr you set up to see if there is a match.

Let me shown a very simple example (the example is run in Interactive C# in Visual Studio Community 2017). Make sure you have already used using System.Text.RegularExpressions before executing these statements:

In the above, the InputStr is 'Jayaram' and the Pattern is shown above. You need to type each line and hit Enter. It is somewhat slow.
In the above case, a match was found for the first lower-case letter in the InputStr.

Here is another example:

The match is for the first upper-case letter in the string.

Here is an example for 2 adjacent numbers in the string:

Only one of the blocks there is a match. Same pattern but different InputStr.





Sunday, April 01, 2018

Python indenting in Python 3.7 Shell (IDLE)

I am using Python Shell from Python 3.7 download from my previous post. The OS is Windows 10 Insiders' Preview 17127.rs4_release.180318-0047

Python 3.7.0b2 (v3.7.0b2:b0ef5c979b, Feb 28 2018, 01:32:48) [MSC v.1912 32 bit (Intel)] on win32
IDLE is Python’s Integrated Development and Learning Environment.

The Shell program has the Options menu where you can change several of settings including Indenting as shown here:





This is a code that threw an exception.



This is after correcting the indentation.




DMCA.com Protection Status