Google+ Peter Bromberg's .NET Blog | All Things Programming

Peter Bromberg's .NET Blog All Things Programming

How to improve the performance of Visual Studio 2017

3. November 2017 13:01 by admin in ASP.NET, C#, VIsual Studio 2017


1. Exclude VS and other tools from Windows Defender.

Here is a list of exclusions for a system with Visual Studio 2017 Professional, ReSharper and Node.js installed.

Processes to Exclude:

// visual studio & tools
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe
C:\Program Files\dotnet\dotnet.exe
// Node.js
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\ServiceHub\Hosts\ServiceHub.Host.Node.x86\ServiceHub.Host.Node.x86.exe
// Node.js (if installed separately or upgraded)
C:\Program Files\nodejs\node.exe

Folders to Exclude:

// project folder (Whatever folder(s) you use for projects)
// visual studio & tools
C:\Program Files (x86)\Microsoft Visual Studio 10.0
C:\Program Files (x86)\Microsoft Visual Studio 14.0
C:\Program Files (x86)\Microsoft Visual Studio
C:\Program Files (x86)\MSBuild
C:\Program Files\dotnet
C:\Program Files (x86)\Microsoft SDKs
C:\Program Files\Microsoft SDKs
C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv
C:\Program Files (x86)\Microsoft Office
// cache folders
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files

2. Turn off indexing
Indexing Service is another bottleneck, pulling the disk I/O to 100% during builds and installing packages as well as shortening the lifetime of SSD drives.

Open the command prompt, type services.msc, and press enter. At the list of services, scroll down until you find Windows Search service. You’ll notice it has probably a Started status and Automatic startup type. Stop the service and set the startup type to Disabled. Do a system restart.
Search will still work, it just won't use the index.

3. Visual Studio Settings:

The following are recommended settings based on best practices for Visual Studio 2017
You can decide which features to leave enabled based on your own needs.

Environment -> General
Uncheck “Automatically adjust visual experience based on client performance”
Uncheck “Enable rich client visual experience”
Check “Use hardware graphics acceleration if available”
Environment -> AutoRecover
Uncheck “Save AutoRecover information every”
Environment -> Documents
Check “Save documents as Unicode when data cannot be saved in codepage”
Environment -> Keyboard
Set “ForceGC” to ctrl+num1
Set “ReSharper_Toggle” to ctrl+num0 (if ReSharper is used)
Set “ReSharper_EnableDaemon” to ctrl+num8 (if ReSharper is used)
Environment -> Startup
Set “At startup” to “Show empty environment at startup”
Uncheck “Download content every”
Environment -> Synchronized settings
Uncheck “Synchronize settings across devices when signed into Visual Studio”
Projects and Solutions
Uncheck “Track active item in solution explorer”
Check “Lightweight solution load for all solutions”
Projects and Solutions -> Build and Run
Check “Only build startup projects and dependencies on run”
Projects and Solutions -> Web Package Management
Set “Restore on Project Open” to false (for Bower)
Set “Restore on Save” to false (for Bower)
Set “Restore on Project Open” to false (for NPM)
Set “Restore on Save” to false (for NPM)
Text Editor -> General
Uncheck “Track changes”
Text Editor -> All Languages -> General
Uncheck “Enable virtual space”
check “Line numbers”
Uncheck “Navigation bar”
Text Editor -> All Languages -> Scroll Bars
Uncheck “Show annotations over vertical scroll bar”
Text Editor -> All Languages -> CodeLens
Uncheck “Enable CodeLens”
Text Editor -> Basic -> Advanced
Uncheck “Enable full solution analysis”
Text Editor -> C# -> Advanced
Uncheck “Enable full solution analysis”
Text Editor -> Basic, C# -> IntelliSense
Uncheck “Show completion list after a character is deleted”
Set “Snippets behavior” to “Never include snippets”
Text Editor -> CoffeeScript -> CoffeeLint
Set “Enable CoffeeLint” to false
Text Editor -> CSS -> CssLint
Set “Enable CSS Lint” to false
Text Editor -> CSS, HTML, JSON, LESS, SCSS -> Advanced
Set “Show errors as warnings” false
Text Editor -> JavaScript/TypeScript -> EsLint
Set “Enable ESLint” to false
Text Editor -> SQL Server Tools, U-SQL -> Intellisense
Uncheck “Enable Intellisense”
Text Editor -> [Language] -> Formatting -> General
Uncheck everything (if ReSharper is used for formatting assistance)
Uncheck “Suppress JIT optimization on module load (Managed only)”
Uncheck “Enable Edit and Continue”
Debugging -> Just-In-Time
Uncheck “Script”
Uncheck “Enable IntelliTrace”
Node.js Tools
Set “Check for surveys/news” to “Never”
Web Forms Designer
Uncheck “Enable Web Forms Designer”
Windows Forms Designer
Set “Automatically Populate Toolbox” to false
XAML Designer
Uncheck “Enable XAML Designer”

Kudos to developer Burak Tasci ( for many of the above settings.

How to get an assembly's location on the fly

9. August 2017 13:30 by admin in


private string[] GetAssemblyLocation(string[] assemblyNames){string[] locations = new string[assemblyNames.Length];for (int loop = 0; loop <= assemblyNames.Length - 1; loop++){locations[loop] = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic && a.ManifestModule.Name == assemblyNames[loop]).Select(a => a.Location).FirstOrDefault();}return locations;}


string reportPath = GetAssemblyLocation(new string[] { "Reports.dll" })[0];
  System.Reflection.Assembly assembly = Assembly.LoadFrom( reportPath);


Rendering PDF reports as HTML for mobile devices

7. July 2017 05:58 by admin in

One of the big problems with things like Report Server and the RDLC ReportViewer control is being able to render PDF reports in mobile browsers. If you can convert these to HTML on the fly with the right library, mobile browsers will happily render the HTML.

One such library is PDF.js  It is extremely easy to install and you can get a PDF report as HTML.

You can set it up as follows:

  1. Download

  2. Extract the ZIP file (a directory called "pdf.js-gh-pages" will be created).

  3. Copy the following directories to your website:

    • pdf.js-gh-pages/build/
    • pdf.js-gh-pages/web/
      The web/ directory contains a 1 MB PDF file called "compressed.tracemonkey-pldi-09.pdf". This file is only used as an example for the demo and can safely be removed.
  4. If you want to open a PDF from your website with PDF.js, simply link to the viewer and pass the location of the PDF file. For example:

    <a href="/web/viewer.html?file=%2Fyourpdf.pdf">Open yourpdf.pdf with PDF.js</a>

How to get the logged in user's first and last name with Auth0

13. June 2017 15:20 by admin in

Sample code:

public ActionResult Index()


            var nameClaim = ClaimsPrincipal.Current.FindFirst("name");

            if (nameClaim != null && !string.IsNullOrEmpty(nameClaim.Value))


                var welcomeName = ClaimsPrincipal.Current.FindFirst("given_name").Value + " " 

                    + ClaimsPrincipal.Current.FindFirst("family_name").Value;              

                ViewBag.Name = welcomeName;  


            return View();