Banner Ad

Showing posts with label Visual Studio Tips and Tricks. Show all posts
Showing posts with label Visual Studio Tips and Tricks. Show all posts

Sunday, July 17, 2016

Visual Studio 2015 : Unable to open .CSHTML files

By Francis   Posted at   1:19 AM   Visual Studio Tips and Tricks 6 comments
                               
Unable to open CSHTML File in VisualStudio
                                 Visual studio 2015 is very cool IDE. It offers more and more benefits to increase the productivity of a developer. For my local development I’m using VS 2015 “Community” Edition. Also, I have updated with latest “Update 3” from here.

The Problem:
                         But after some days,  when i want to open a .cshtml file in my solution, VS throws some strange isssue, that is a pop up throws with the message “"Operation could not be completed. Invalid Pointer."

The Solution:
                     I’m not pretty much sure, this error is because of “Update 3”. But i soloved this issue by following the below steps:

  1. Close your VS instance
  2. Open the “Run” dialog (by pressing the short cut Windows Key +R).
  3. Type “%LocalAppData%” (without quotes).
  4. It will open the path “C:\Users\YOURUSERNAME\AppData\Local” in that navigate to “Microsoft –> Visual Studio –> 14.0 –>ComponentModelCache”.
  5. It contains some “cache” files, just delete them all.
  6. Now open the VS 2015 again. You can open the .cshtml files, without any problem.
The above trick, worked for me. This issue also discussed in this github thread. There are various solutions disscused over there, but i found this one is working for me, which is among one they discussed.

If you are one of the victim, hope this post may be useful for you!  Smile

Sunday, February 7, 2016

Visual Studio Tips and Tricks -13 : Debugging with Visual Studio

By Francis   Posted at   3:15 PM   Visual Studio Tips and Tricks No comments
Visual Studio is a great IDE for developing all type of Microsoft desktop/web stack applications. There is no doubt on that!. One of the main feature provided in Visual Studio is it’s capability provide more options to debugging the applications. In this post I explained some basic concepts about debugging in Visual Studio.


You can also check my other Visual Studio Tips here.

Setup the environment:

In this post I’m using Visual Studio 2015 Community edition. Based on your version of Visual studio some options may differ. For simple and neat explanation, here I’m going to use a simple for loop C# code snippet.

So What is breakpoint?
When you run the program in Visual Studio IDE, if you want to check the execution of a particular routine or function at that time you can set the breakpoint. Probably, it set before to run the application. So when the program executes, the breakpoint hits and the program waits there. So that you can step into the program and take a deep look into the code and check the values there itself. This is the main advantage of breakpoints.

Set normal Breakpoint:
Set the breakpoint in an application is very simple. You can hit the F9 key or you can click on the left most border in Visual Studio. It will keep the break point on the particular line.
After setting the break point, Visual Studio indicate the particular line with the Red color and preceded with a dot like below.

Breakpoint-in-VisualStudio
Breakpoint-in-VisualStudio

In these kind of break points, it will hit without any conditions. So whenever, the execution cross the line it will simply hit there.

Set Conditional Breakpoint:
So as we discussed in the previous section,say for example, if we set the break point with in a loop it will hit the break point without any condition. So the break point is hit often. Instead of this, we may want to set some conditions. Let’s see how we can do it.

1. Right click on the break point and select “Conditions…” in the context menu.
Conditional-Breakpoint-Menu
Conditional-Breakpoint-Menu
2. Visual Studio 2015 offers the below “Breakpoint Settings” window to set up the condition.
Conditional-Breakpoint-Window
Conditional-Breakpoint-Window
3. Here I’m going to set the “Conditions” as : When the counter value(i) is greater than 5 at that time it will hit the break point. That means, till the value of the counter value is 5, it will not hit. After that it will hit.
Setting-Conditions
Set-Conditions
In some cases you may want to track based on some process id or thread id etc. Visual studio also give options for this.

Breakpoint-Window-Filter
In some cases, we want to count the “Hit count”,meant whenever the break point hits it will consider as a hitcount. You can specify it by selecting “Hit Count” list item as below:
Breakpoint-Window-HitCount
Breakpoint-Window-HitCount

Set Actions:
“Breakpoint Settings” window also offers that log message to Output window. At that you can make use of “Actions”. There are some special keywords are there, which have a special meaning when you use in the “Action” text box.

Breakpoint-Window-Action-SpecialKeyword
Breakpoint-Window-Action-SpecialKeyword
When you specify Action alone, there is a checkbox named “Continue execution”, if you check this the breakpoint will not hit. You can see the message in the “Output Window”.
Breakpoint-Window-Specify-Action
Breakpoint-Window-Specify-Action
Breakpoint-Window-Result-in-OutputWindow
Breakpoint-Window-Result-in-OutputWindow
  In the above action, we specify the special keyword "$Function", which prints the current function name as you see in the above screen shot.

Disable Break points:
In some cases, you may want to continue the execution of your program without hitting the breakpoints and later cases you may need them. At that time you can use the "Disable Breakpoint" option by using the short cut key "Ctrl + F9" key. Later cases, you can use the same short cut key to "Enable Breakpoint". You can make use of these options during run time also.

Disabled-Breakpoint
Disabled-Breakpoint
Readers, hopefully this tutorial helps you to understand about the various debugging options provided by Visual Studio. Let me know your thoughts as comments. Happy programming!



Sunday, October 25, 2015

Visual Studio : How to install Nuget packages in your project?

By Francis   Posted at   2:00 AM   Visual Studio Tips and Tricks No comments
               In this article I’m going to explain about how to install/uninstall Nuget packages for your application in Visual Studio using “Nuget Package Manager” and “Package Manager Console”. I assume that you have Visual Studio 2013/2015 on your machine.
                    Before that, if you are not aware about “Nuget” means, the below sentence is for you:
                  “NuGet is the package manager for the Microsoft development platform including .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery is the central package repository used by all package authors and consumers.”
Install Nuget Package using ‘Nuget Package Manager’:
Step 1:
Rightclick on your project and select  “Manage Nuget Packages”.


Step 2:
Now the “Nuget Package Manager” window will appear with the list of nuget packages.

Step 3:
In the search box, type the package you look for and hit enter. In this example, I just searched for “routedebugger” package and installed it by clicking the “Install” button.

Step 4:
While installing if the downloaded package tries to change the files in the solution/project it will popup the dialog to warn us. Just click “OK” for it and you can see the “installation progress” in the Output window.


Step 5:
Now you can just expand the “Solution Explore” window, see in the “Reference” to check that particular reference is added or not.

Uninstall NuGet Package using ‘Nuget Package Manager’:
Step 1:
If you want to uninstall, again go to the “Nuget Package Manager” and search for the particular package.Visual Studio automatically finds that particular package is installed on not and now you can see the “Uninstall”  button.


Step 2:
Since it made some changes in the project while installing, so it will automatically revert the changes in the file. So again it will popup the dialog. just click “OK”. Also in output window you can see the uninstall status.





Install NuGet Package using ‘Package Manager Console’:
Alternatively, you can use the “Package Manager Console” in Visual studio to install the necessary packages by running the respective command.
Step 1:

Go to www.nuget.org and type the package name in the search box and go to the particular package’s page, there you can find the “Package Manager Console” command.



Step 2:
To open the Package Manager Console, Tools –>NuGet Package Manager –> Package Manager Console.

Just copy the command from above website and paste it on the package manager console and hit enter.


Note :  Before hit enter key, just check the project name in the “Default project” dropdown. Incase, if you have lot of projects, you must pay attention on this by selecting correct project.
Uninstall NuGet Package using ‘Package Manager Console’:
Step 1:
In order to uninstall, just type the below command in the “Package Manager Console” and hit enter, it will uninstall the package: Uninstall-Package routedebugger.


That’s all! Hope this will helpful for someone!! Let me know your thoughts as comments!

Sunday, July 26, 2015

Visual Studio Tips and Tricks-12 : Create ASP.NET 5 Website in Visual Studio 2015(Community Edition)

By Francis   Posted at   11:19 AM   Visual Studio Tips and Tricks No comments

1) Open Visual Studio 2015.

2) Select File –> New –> Project

3) In the “New Project” window, select Templates –> Visual C# –> ASP.NET Web Application. Give valid name and select location then click “OK”.

NewProject-Window

4) During this post, ASP.Net 5 is in Preview. So in the next screen you can see the “ASP.Net 5 Preview Template” and select “Website”.

TemplateWindow

5) That’s it! You have created ASP.Net 5 website. It looks like below:

ASPNet5_Website

 

Happy Coding!!!

Monday, June 29, 2015

Visual Studio Tips and Tricks–11 : Various ways to open Visual Studio IDE in Windows

By Francis   Posted at   10:51 AM   Visual Studio Tips and Tricks No comments

In my previous articles I have explained various of tips and tricks for Visual studio. In this post i ‘m going to explain various ways that are available to open the Visual Studio IDE.

 

Way #1:

Click the Start button and type “v” in the “search” box. It will listed the programs (including Visual Studio) and select the Visual Studio.

image

 

Way #2:

Click “Start” button and type “devenv” in “Search” box. “Devenv” is the short form for “Development Environment”, which denotes Visual Studio in Windows OS.

 

image

 

Way #3:

Windows 7 offers the concept called “pin and unpin the programs” in task bar. Just pin the Visual Studio in task bar as shown below. This is another shortcut to open VS in a quicker manner.

image

Monday, January 19, 2015

Visual Studio Tips & Tricks–10 : How to Change the color theme in Visual Studio 2015?

By Francis   Posted at   7:41 PM   Visual Studio Tips and Tricks No comments
                                  Go to Tools –> Options Menu. In the Options dialog, expand “Environment” and then select “General” node. On the right hand side, under the heading “Visual experience”, you can find the “Color theme” dropdown, which contains the the list of themes. Select one of them, you interested and click “OK”. That’s all you have changed the theme successfully!!

Tools_Menu

Options_Menu

Tuesday, March 11, 2014

Visual Studio Tips & Tricks - 8: Breakpoint will not currently be hit. No symbols have been loaded for this project.

By Francis   Posted at   5:50 PM   Visual Studio Tips and Tricks 2 comments

Most of the developers who are using Visual studio have encountered the above problem. As a ASP.Net Developer I have this atleast once a day. So the below are my tricks to get ride of this issue.

 

1) Just Close the VS IDE.

2) Go to Task Manager and kill the worker process. (If you are working on  ASP.Net application).

3) Go to the .Net installation folder ( Normally it should be C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files OR C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files) and clear the temp files from the temporary folder.

4) Open the solution and "Rebuild" entire solution. Now try to attach the debugger.

 

Please note that, in some machines you may have 2 framework installation, one for 32-bit and another for 64-bit. So when you go with step 3, pay close attention and make sure which .net framework was used and also which version no (either 2,3,3.5 or 4) was used by your application.

 

Hope this helps!

Wednesday, March 5, 2014

VisualStudio Tips & Tricks - 7 : Using Transact-SQL Editor in Visual Studio 2010

By Francis   Posted at   10:13 AM   Visual Studio Tips and Tricks No comments
                           Few months ago, when we upgrade from VSS to TFS, somehow we lost intellisense in SQLServer Management studio 2008 R2. We struggle a lot to obtain. But no luck till now. However, currently we are using Visual Studio 2010, which enriched with lot of futures.
            Instead of using SQL Server Management, what I did was open the SQL file using Visual Studio 2010. In Visual Studio, Right click on the Menu bar, from the floating menu “check” the “Transact-SQL Editor”.

image
Now we got the toolbar available in SQL to do some basic operations like connect the SQL Server, Execute the Transact SQL etc., The main benefit in this approach is the intellisense works fine with in the “Transact-SQL Editor”. So my problem solved temporary.
One of the main attraction in this feature is, we can do all basic operations with in this editor. However, I’m not at all a DBA, just a developer who used SQL server as a backend. This is more convenient way work as of now.

Hope this may help to some one!!

Tuesday, March 4, 2014

Visual Studio Tips & Tricks – 6 : Multi-Copy functionality in Visual Studio

By Francis   Posted at   12:26 PM   Visual Studio Tips and Tricks No comments

                                    Some time we may need to copy the multiple code snippets (that is we may need to copy and paste lines that are not in order) in a file and paste it in another location of the file inside Visual Studio. For example, we have 5 lines of text, what we need is to copy the 1,3 and 5 line of text and paste it on some other location. To achieve that functionality to do the following:

 

1) Copy the code snippets using Ctrl+C key combination. (That is select the line 1 and press Ctrl + C and select line 3 press Ctrl + C and so on).

2) When you paste that code press the key combination Ctrl + V + Shift key, which rotates the copied lines of text. To paste a particular selected text just press Ctrl + V.

 

Hope this helps to some one!

Friday, October 25, 2013

Visual Studio Tips & Tricks - 5 : Class Library – An Introduction

By Francis   Posted at   3:47 PM   Visual Studio Tips and Tricks No comments
                      Class Library is a one of the project type offered in Visual Studio. Normally a class library contains class definition or interface. If we use the class library in projects we can gain the below advantages:

  •             Provide a single DLL regardless of class files. That is a class library contains number of class files. But the output of the class library is a Single “DLL” (Dynamic Link Library) File.
  •        The main purpose of the class library comes into picture in a layered architecture projects.For example, a web project contains various layers (such as Business and Data Access Layers). If we use a separate class library for each layer, in this case if any layer changed we just compiled that particular layer and get the dll and replace it in Production environment.  At these times, class library project type are best option.


Readers do you have any tip? Please use comment.

Monday, October 14, 2013

Visual Studio Tips & Tricks: 5 - Hexa Decimal values displayed during Debug the application

By Francis   Posted at   9:27 AM   Visual Studio Tips and Tricks No comments
                  Recently, I had a wired problem in Visual studio. In this post i’m going to discuss about it. The problem is, when I try to debug my application in Visual Studio 2010, the values are displayed in Hexadecimal format. Please take a look into the below picture.
Hexa Decimal values displayed during Debug the application
Values of Variable Displayed in Hexa Decimal Format
The reason is somehow the “Hexadecimal Display” option has been checked in the “Watch” window.
“Hexadecimal Display” option in Watch Window
“Hexadecimal Display” option in Watch Window

So that all the values are displayed in Hexadecimal form in watch window too.
So just disable the “Hexadecimal Display” in the watch window’s float menu. The display will correctly display in the decimal form.
Values of Variable Displayed in Decimal Format
Values of Variable Displayed in Decimal Format


Hope this helps someone!

Monday, August 26, 2013

Visual Studio Tips &Tricks: 4 – Solution File Not Found

By Francis   Posted at   11:19 AM   Visual Studio Tips and Tricks No comments
                  Last night I have tried to add a Blank Solution and then to add a website under that solution. First I have added that blank solution. Solution added successfully. When I added the Website under that solution, then the Solution has been hidden only website alone displayed in Solution Explorer.

Website With out Solution

To Bring the Solution file, go to the Tools -> Option Menu.

Select “Projects and Solutions” and check the check box with the text “Always show solution”. 
Option Window in Visual Studio
That’s all now the solution file displayed in the top of web site like below.
Website with Solution

Hope this helps a bit!

Thursday, August 22, 2013

Visual Studio Tips &Tricks : 3 – Ctrl+, - File Search Easy

By Francis   Posted at   11:28 AM   Visual Studio Tips and Tricks No comments
                 Whenever the project grows large it’s hard to take the necessary file in Visual studio. That is we need to traverse a lot of folders or sub folders if we know the file where it was exactly. 

                  Sometimes, when you deployed in a new project, if another user just mention a file name and ask you take a look about particular logic its really painful to find that file where it was located exactly.

                   At these times the hot key combination Ctrl + , (Control Key with Semicolon) comes a handy. Which opens “Navigate To” window in which if we started type it will list down the file name in a quicker manner. So that we can pick up the file easily.
Navigate To - Window 

                   It not only listed the File names, it also list down the method name too. So whether you search a method or File use the 
shortcut key Ctrl+, and navigate quicker.

Please give your valuable comments which improves my future articles!

Hope this helps a bit!

Monday, August 19, 2013

Visual Studio Tips & Tricks: 2 – Create Virtual Directory Problem

By Francis   Posted at   12:15 PM   Visual Studio Tips and Tricks No comments
                     Few days ago, I just want to create a virtual directory for my ASP.Net web project. I just go to the “Solution Explorer” and “Right click” on the Web project in the floating menu choose the “Properties” of the Web project.

Project Properties Float Menu

              In the Properties page, Select “Web” Tab and select the option “Use Local IIS web Server” and then click “Create Virtual Directory” button. At that time the below error occurred:

Unable to create the virtual directory. To access local IIS Web sites, you must run Visual Studio in the context of an administrator account.

Virtual Directory Creation Error

Thursday, June 20, 2013

Visual Studio Tips & Tricks

By Francis   Posted at   11:31 AM   Visual Studio Tips and Tricks No comments
Visual Studio Tips & Tricks - 1:

One of the best feature of Visual Studio is it’s Documentation facility, which is used to comment the functions, procedures automatically. In VS, you can achieve that by putting three single quotes sequentially (See the image below). There is no doubt it’s a one of the good feature of VS.
Auto Comment Facility Provided by Visual Studio

         Few days ago, in my VS Solution which use more than one projects these feature doesn’t work. It’s because the documentation feature not enabled. To enable this feature to do the following:

RightClick Project ->Select “Properties”  ->Select “Compile” tab ->Check the “Generate XML documentation file"

Enable/Disable Documentation Feature for a Project

That’s all the problem solved. Hope this helps!

Happy Coding!!
Connect with Us