Visual Studio Tips, Tricks Archives - Anuj Varma, Hands-On Technology Architect, Clean Air Activist https://www.anujvarma.com/category/technology/languages-platforms-object-oriented-observations/visual-studio-tips-tricks/ Production Grade Technical Solutions | Data Encryption and Public Cloud Expert Mon, 24 May 2021 23:35:42 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 https://www.anujvarma.com/wp-content/uploads/anujtech.png Visual Studio Tips, Tricks Archives - Anuj Varma, Hands-On Technology Architect, Clean Air Activist https://www.anujvarma.com/category/technology/languages-platforms-object-oriented-observations/visual-studio-tips-tricks/ 32 32 dotnet nuget updates https://www.anujvarma.com/dotnet-nuget-updates/ https://www.anujvarma.com/dotnet-nuget-updates/#respond Wed, 13 Jan 2021 03:27:17 +0000 https://www.anujvarma.com/?p=8106 Error: error MSB4236: The SDK ‘Microsoft.NET.Sdk.Razor’ specified could not be found. Try this fix: dotnet nuget locals all -c Other helpful dotnet core commands dotnet restore dotnet build dotnet run […]

The post dotnet nuget updates appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

]]>
Error: error MSB4236: The SDK ‘Microsoft.NET.Sdk.Razor’ specified could not be found.

Try this fix:
dotnet nuget locals all -c

Other helpful dotnet core commands

  • dotnet restore
  • dotnet build
  • dotnet run (csproj) or dotnet mydll.dll (no run required)
  • dotnet test
  • dotnet publish
  • dotnet pack
  • dotnet new (project or solution)
  • dotnet build-server

The post dotnet nuget updates appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

]]>
https://www.anujvarma.com/dotnet-nuget-updates/feed/ 0
Running node.js apps from within VS 2017 https://www.anujvarma.com/running-node-js-apps-from-within-vs-2017/ https://www.anujvarma.com/running-node-js-apps-from-within-vs-2017/#respond Mon, 08 Jan 2018 00:53:39 +0000 http://www.anujvarma.com/?p=5037 Make sure you are running VS 2017 or VS 2015 as Administrator. From the node.js main.js file – Right click and open a command prompt in the containing folder. You […]

The post Running node.js apps from within VS 2017 appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

]]>
  • Make sure you are running VS 2017 or VS 2015 as Administrator.
  • From the node.js main.js file – Right click and open a command prompt in the containing folder.
  • You should be able to type node main.js – provided the node location is in your PATH variable.
  • The post Running node.js apps from within VS 2017 appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/running-node-js-apps-from-within-vs-2017/feed/ 0
    Lost intellisense in Visual Studio https://www.anujvarma.com/lost-intellisense-in-visual-studio/ https://www.anujvarma.com/lost-intellisense-in-visual-studio/#respond Wed, 06 May 2015 22:31:52 +0000 http://www.anujvarma.com/?p=3093 If you just lost intellisense in VS 2012 or 2013, you are not alone. These are the two most common culprits/fixes – RESET all settings –  Tools > Import and […]

    The post Lost intellisense in Visual Studio appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    If you just lost intellisense in VS 2012 or 2013, you are not alone. These are the two most common culprits/fixes –

    1. RESET all settings –  Tools > Import and Export Settings... > Reset all settings. (This always works for me).
    2. Close Visual Studio , Delete yoursolution.suo file. Reopen Visual Studio and reload your project. (This works some of the time).

    There are other possible reasons for losing intellisense  – but these two fixes usually work.

    The post Lost intellisense in Visual Studio appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/lost-intellisense-in-visual-studio/feed/ 0
    Visual Studio 2013 javascript error while running in DEBUG mode https://www.anujvarma.com/visual-studio-2013-javascript-error-while-running-in-debug-mode/ https://www.anujvarma.com/visual-studio-2013-javascript-error-while-running-in-debug-mode/#respond Thu, 22 Jan 2015 19:34:29 +0000 http://www.anujvarma.com/?p=2833 If you encounter a javascript error only when running through Visual Studio (and not standalone), then you are probably running into this new feature in Visual Studio 2013 – called […]

    The post Visual Studio 2013 javascript error while running in DEBUG mode appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    If you encounter a javascript error only when running through Visual Studio (and not standalone), then you are probably running into this new feature in Visual Studio 2013 – called Browser Link.

    It is a two way communication between Visual Studio and your launched app (using Signal R , I believe). 

    To disable this feature, add the following key to Web.config:

    <appSettings>

      ...

    <add key="vs:EnableBrowserLink" value="false" />

    </appSettings>

    The post Visual Studio 2013 javascript error while running in DEBUG mode appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/visual-studio-2013-javascript-error-while-running-in-debug-mode/feed/ 0
    Intellisense disappears after Resharper Uninstall https://www.anujvarma.com/intellisense-disappears-after-resharper-uninstall/ https://www.anujvarma.com/intellisense-disappears-after-resharper-uninstall/#respond Fri, 15 Aug 2014 19:49:11 +0000 http://www.anujvarma.com/?p=2668 I lost Intellisense – and had some trouble getting it back. One thing to try is to delete the .suo file (usually at the Solution level) – after shutting down […]

    The post Intellisense disappears after Resharper Uninstall appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    I lost Intellisense – and had some trouble getting it back.

    1. One thing to try is to delete the .suo file (usually at the Solution level) – after shutting down Visual Studio. Try restarting VS and see if you recover Intellisense.  The thing that fixed it for me was the following:  
    2. Options pane under Text Editor/General (and also Text Editor / C#).

    Make sure the Auto List Members and Parameter Information are CHECKED ( as shown below). That’s it- that should recover your intellisense.

    vs_loses_intellisnse

    The post Intellisense disappears after Resharper Uninstall appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/intellisense-disappears-after-resharper-uninstall/feed/ 0
    Visual Studio – VS find matching brace https://www.anujvarma.com/visual-studio-vs-find-matching-brace/ https://www.anujvarma.com/visual-studio-vs-find-matching-brace/#respond Wed, 12 Mar 2014 22:57:02 +0000 http://www.anujvarma.com/?p=2312 1. Place your cursor either before or after the OPENING brace. 2. Type CTRL ]   (CTRL and CLOSE BRACKET) – it should jump to the closing brace

    The post Visual Studio – VS find matching brace appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    1. Place your cursor either before or after the OPENING brace.

    2. Type CTRL ]   (CTRL and CLOSE BRACKET) – it should jump to the closing brace

    The post Visual Studio – VS find matching brace appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/visual-studio-vs-find-matching-brace/feed/ 0
    Visual Studio Using Too Much Memory https://www.anujvarma.com/visual-studio-using-too-much-memory/ https://www.anujvarma.com/visual-studio-using-too-much-memory/#respond Thu, 12 Dec 2013 20:22:48 +0000 http://www.anujvarma.com/?p=2156 When running by itself (no project opened and no extensions), Visual Studio 2012 takes less than 100 MB. When you open up your projects, those add to the total memory […]

    The post Visual Studio Using Too Much Memory appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    When running by itself (no project opened and no extensions), Visual Studio 2012 takes less than 100 MB. When you open up your projects, those add to the total memory of course. However, if you find Visual Studio (2012) using excessive memory (a co-worker noticed 700MB , when the size of our solution was less than 100MB), there’s a couple of places to look. First, Extensions and Updates (under Tools).

    Extensions (under the Tools menu)

    1. Memory leaks in extensions – Some extensions are just poorly behaved and known to have memory leaks. This may explain why when you perform certain tasks from  VS , you see your memory usage spike. .NET Reflector from jetbrains was causing one such issue. 
    2. Too many unused extensions – Disable (or uninstall) any extensions that you are not using.

    Add-Ins (also under the Tools menu)

    The same considerations apply to add-ins which get loaded on VS startup. Go through and remove the add-ins that are not being used.

    Once we figured these out, the memory usage went down from 700 MB to 200 MB.

    The post Visual Studio Using Too Much Memory appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/visual-studio-using-too-much-memory/feed/ 0
    Visual Studio Replace multiple lines of code https://www.anujvarma.com/visual-studio-replace-multiple-lines-of-code/ https://www.anujvarma.com/visual-studio-replace-multiple-lines-of-code/#respond Fri, 29 Nov 2013 14:26:00 +0000 http://www.anujvarma.com/?p=2193 I had to insert a few lines of code in about 700 different files. However, the insertion had to be in a specific place (just before the start of a […]

    The post Visual Studio Replace multiple lines of code appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    I had to insert a few lines of code in about 700 different files. However, the insertion had to be in a specific place (just before the start of a transaction – so just before using (var transaction = session.BeginTransaction).
    The regular Find and Replace would not work, since I needed to insert a linefeed to separate the lines of code. The linefeed mandated using regular expressions. The replace term would need to contain \n wherever a line feed was needed.

    The Search Part

    However, even though I had no NEED for regex in my search term, I still HAD to make the search term RegEx friendly. For example, the open parenthesis in using (var , had to be made RegEx friendly.  Fortunately, all this meant was escaping (the open parenthesis ‘(‘) with a backslash – as in \( .
    The snapshot shows what my my enusing \(var transaction – replaced with NewLineOfCode1 and NewLineOfCode2 would look like. The \t is used to align the new lines of inserted code with the existing line (using \(var.  The \n is the newline insert between two lines of code.

    1. Notice that ‘Use Regular Expressions’ is checked.
    2. Notice that I still retain the using (var…part – I am doing an insert of additional lines of code – NOT  replacing existing lines of code. The same pattern could be applied for a pure REPLACE as well, of course.
    3. You can optionally apply a filter for choosing the files you apply this to – for e.g. *.cs files etc.

    regexfindandreplace

    Summary

    Using the Regular Expressions Search and Replace allows for replacing / inserting multiple lines of code within multiple source code files in your solution. All you have to do is make your search term RegEx friendly.

    The post Visual Studio Replace multiple lines of code appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/visual-studio-replace-multiple-lines-of-code/feed/ 0
    Visual studio does not display .NET 4.0 (or 4.5) framework option for target framework https://www.anujvarma.com/visual-studio-does-not-display-4-0-or-4-5-framework-option-for-target-framework/ https://www.anujvarma.com/visual-studio-does-not-display-4-0-or-4-5-framework-option-for-target-framework/#comments Thu, 21 Nov 2013 19:15:36 +0000 http://www.anujvarma.com/?p=1848 Introduction Even if you have .NET framework 4.0 (or above) installed correctly, Visual Studio sometimes does not pick it up. This means that you will be unable to convert any […]

    The post Visual studio does not display .NET 4.0 (or 4.5) framework option for target framework appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    Introduction

    Even if you have .NET framework 4.0 (or above) installed correctly, Visual Studio sometimes does not pick it up. This means that you will be unable to convert any of your projects to compile against 4.0 (by setting the ‘build target’ to 4.0 or above). Simply changing the ‘target platform’ setting in the web.config to 4.0 does not do anything. You actually need to go through Visual Studio’s –>Project Level –> Properties –> Build –> Target Framework (or Application—>TargetFramework) – and set it to the framework of choice. In my case, I DID NOT see 4.0 or 4.5 (in spite of having both of these frameworks installed on my machine).

    MISSING Framework 4.0 and 4.5

    build_target_dotnet_framework 

    First thing I learned was that Visual studio uses the following path to CHECK for these installed frameworks (it is the folder for referenced assemblies – referenced by VS, I am guessing):

    C:\Program Files\Reference Assemblies\Microsoft\Framework\xxx

    For each installed framework, there is a folder (v3.0, v3.5) as shown below containing the assemblies that VS needs for its tasks.

     

    dotnet_framework_4.0_reference_assemblies

    As you can see, v4.0 is missing. I had this issue on my computer – and re-installing the 4.0 framework did not address it.

    This folder is needed only by Visual Studio, so I thought maybe reinstalling Visual Studio will do the trick.  That did not work either.

    When this folder goes missing, it seems impossible to bring it back by doing a re-install.

    TWO Solutions

    Solution 1 (Recommended)

    Try downloading and installing Visual studio 2013 (from here). That will install all the required .NET frameworks correctly – in places where Visual Studio needs to look for them.

    Solution 2 (may work)

    Another solution that worked for me was to copy this folder (v4.0 folder from another machine that had the v4.0 folder) – into the Framework folder above. This seemed to make Visual Studio happy and I could now pick v4.0 for my ‘target framework’ for my VS projects.

    Summary

    Visual Studio’s inability to pick up the correct .NET framework seems to be an annoyance – and re-installing BOTH Visual Studio and the framework does not seem to help. What worked for me was installing the latest version of Visual Studio (2013). You can also try the folder copying trick for a time saving solution. Once I installed VS 2013, I was able to see the correct framework versions in my ‘build target’ dropdown.

    application_target_dotnet_framework

    The post Visual studio does not display .NET 4.0 (or 4.5) framework option for target framework appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/visual-studio-does-not-display-4-0-or-4-5-framework-option-for-target-framework/feed/ 7
    Source file ‘\Properties\AssemblyInfo.cs’ could not be opened (‘Unspecified error ‘) https://www.anujvarma.com/source-file-propertiesassemblyinfo-cs-could-not-be-opened-unspecified-error/ https://www.anujvarma.com/source-file-propertiesassemblyinfo-cs-could-not-be-opened-unspecified-error/#comments Thu, 31 Oct 2013 22:18:21 +0000 http://www.anujvarma.com/?p=1661 Introduction You’ve just downloaded a project (from either codeproject or github or some other repository) – and opened it up in your current version of Visual Studio. On trying to […]

    The post Source file ‘\Properties\AssemblyInfo.cs’ could not be opened (‘Unspecified error ‘) appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    Introduction

    You’ve just downloaded a project (from either codeproject or github or some other repository) – and opened it up in your current version of Visual Studio.

    On trying to compile it, you encounter the following error:

    AssemblyInfo.cs’ could not be opened (‘Unspecified error ‘)

    This seems to occur for every project in your solution that contains an AssemblyInfo.cs. Simply put,  the assemblyinfo.cs contains ‘metadata’ (version number, guid etc.) for your assembly. This metadata is useful in uniquely identifying your assembly to all its consumers.

    Workaround 1

    Simply delete these assemblyinfo.cs files. If all you are trying to do is view sample source code, you do not really care about the versioning or COM interoperability (GUID) of the assembly. Your project should compile just fine after this deletion.

    Workaround 2

    If deleting the file is not an option – and you do need the metadata, simply delete the offending file – and create a new one. To create a new one, click on the ‘Properties’ folder in your project (see below). This should bring up the properties dialog. There should be an ‘Assembly Information’ button.

    properties_assembly_info

    Now, the only thing the assembly information really needs is a GUID. From your Tools menu—>CreateGUID as shown below.

    createguid

     

    Click ‘Copy’ on the CreateGUID popup – and paste that content into the Assembly Information screen from the previous step. Delete the leading slashes in the GUID, since you do not need those.

    createguid1

    Click OK – and you should be done. You will have an assemblyinfo with a GUID – and your project will compile just fine.

    Summary

    While uploading projects, the assemblyinfo.cs file often goes missing – and causes a compilation error for users who try downloading and compiling the project. The workaround is simple – either delete the file altogether (you don’t need it) – or delete and re-create it using the steps described in this post.

    The post Source file ‘\Properties\AssemblyInfo.cs’ could not be opened (‘Unspecified error ‘) appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

    ]]>
    https://www.anujvarma.com/source-file-propertiesassemblyinfo-cs-could-not-be-opened-unspecified-error/feed/ 1