<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Rohith's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/rohithrajan/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/rohithrajan/feed.xml</link>
    <description>All about full stack development ...</description>
    <lastBuildDate>Mon, 09 Apr 2018 06:26:03 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>docker: Error response from daemon: driver failed programming external connectivity on endpoint</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/docker-error-response-from-daemon-driver-failed-programming-external-connectivity-on-endpoint</link>
      <pubDate>Mon, 09 Apr 2018 04:42:26 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=455</guid>
      <description><![CDATA[This one is going to be quick post where I ran into following error with docker while trying to...]]></description>
      <content:encoded><![CDATA[This one is going to be quick post where I ran into following error with docker while trying to start a mssql linux container from a windows 10 machine
<pre>E:\&gt;docker run -p 1433:1433 --name mssqlverification -v mssqldata:/var/opt/mssql/data -d company/mssql-external
ba97afdcaf554a8af81c946896940ad071c3bb9b3924889dae05bcb7821e56b1
docker: Error response from daemon: driver failed programming external connectivity on endpoint mssqlverification (07e38668d0f1a46dddd97585377310f80b330ddb281771d33f5556900b5da9fd): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:1433:tcp:172.17.0.2:1433: input/output error.</pre>
There are many github issues like <a href="https://github.com/docker/compose/issues/3277">this one</a> and <a href="https://github.com/jwilder/nginx-proxy/issues/839">this</a>,<a href="https://github.com/zodern/meteor-up/issues/631">this  </a>opened for the same issue . I followed these steps and it worked fine for me.Hope any of this steps help you
<ul>
 	<li>Check if the port is already used by any other process with these command</li>
</ul>
<pre>netstat -ano|find ":1433"</pre>
1433 is the port you are looking for .If this command  returns any output,you have to stop the process using that port.

e.g for port 3001
<pre>E:\&gt;netstat -ano|find ":3001"
 TCP 0.0.0.0:3001 0.0.0.0:0 LISTENING 8548
 TCP [::1]:3001 [::]:0 LISTENING 8548

E:\&gt;tasklist|find "8548"
vpnkit.exe 8548 Console 3 24,116 K</pre>
In the above command ,I was running another docker on port 3001 and vpnkit was used by docker itself.
<ul>
 	<li>Check the hello world container works for you</li>
</ul>
&nbsp;
<pre>E:\&gt;docker run -it hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 (amd64)
 3. The Docker daemon created a new container from that image which runs the
 executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
 to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/</pre>
Also if you are on windows ,you can also check whether you are using Linux Or Windows Containers.You can change to windows containers from the docker tray on windows as shown below

<a href="https://msdnshared.blob.core.windows.net/media/2018/04/switch-to-windows-containers.png"><img src="https://msdnshared.blob.core.windows.net/media/2018/04/switch-to-windows-containers-194x300.png" alt="switch to windows containers" class="aligncenter wp-image-465 size-medium" width="194" height="300" /></a>

Now you have to rerun the hello world again and verify.
<pre>E:\&gt;docker run -it hello-world</pre>
<ul>
 	<li>If the issue is with the Linux Containers,stop the docker and restart your machine.  This should solve the issue.</li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>Curious case of IISExpress error "Failed to register URL" when working with OWINHost</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/curious-case-of-iisexpress-error-failed-to-register-url-when-working-with-owinhost</link>
      <pubDate>Wed, 28 Mar 2018 13:23:52 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=435</guid>
      <description><![CDATA[when working with an application using a bunch of micro services , ran into this error with...]]></description>
      <content:encoded><![CDATA[when working with an application using a bunch of micro services , ran into this error with iisexpress
<blockquote>Failed to register URL "http://localhost:3001/" for site "Contoso.Web" application "/". Error descriptio
n: Cannot create a file when that file already exists. (0x800700b7)</blockquote>
<pre>C:\Program Files\IIS Express&gt;iisexpress /config:D:\PROJECTS\api\.vs\config\applicationhost.config /trace:error
Starting IIS Express ...
Initializing the W3 Server Started CTC = -1673430150
W3 Server initializing WinSock. CTC = -1673430134
W3 Server WinSock initialized. CTC = -1673430118
W3 Server ThreadPool initialized (ipm has signalled). CTC = -1673430118
Start listenerChannel http:0
Failed to register URL "http://localhost:3001/" for site "Contoso.Web" application "/". Error descriptio
n: Cannot create a file when that file already exists. (0x800700b7)
Failed to initialize site bindings
Error initializing ULATQ. hr = 800700b7
Terminating W3_SERVER object
InitComplete event signalled
Process Model Shutdown called
Unable to start iisexpress.

Cannot create a file when that file already exists.
For more information about the error, run iisexpress.exe with the tracing switch enabled (/trace:error).</pre>
So iisexpress is complaining that another process is already sing the port 3001. But I was sure that no other process is using the port 3001. I had checked using all the methods explaining in my own post <a href="http://how-to-fix-the-error-port-is-currently-used-by-another-application">how-to-fix-the-error-port-is-currently-used-by-another-application</a>

But still IISExpress is not able to bind to the port 3001. I knew one thing  where this port was used by another microservices . We had a total of 4 services and one of them was running inside IIS and other 3 were running as a OWIN HOST inside different windows services (using <a href="https://github.com/Topshelf/Topshelf">TopShelf</a>.)

When I tested my owin service on the same port,it is able to bind fine. You can see owin host starting code below

[code lang="csharp"]

WebApp.Start(hostAdress, appBuilder 
{
//application initialization code
});

[/code]

This code is using Microsoft.Owin.Hosting to start a OWIN web server in the hostaddress .in our case hostaddress was http://localhost:3001.

So it seems OWIN is able to bind but iisexpress is not able to . I tried many things
<ul>
 	<li>Run both IISExpress and OWIN Services under administrator</li>
 	<li>Added urlacl for http://localhost:3001</li>
</ul>
netsh http add urlacl url=http://localhost:3001/ user=Everyone
<ul>
 	<li>removed urlacl</li>
</ul>
<blockquote>netsh http delete urlacl http://+:3001/</blockquote>
None of this seems to fix the iisexpress error. Then it struck me,even though we started the OWINHost using WebApp.Start, in the code,it was never stopped. This process which OWINHost is running is exited but  the entry did not get removed from the http.sys.

&nbsp;

So in order to stop an OWINHost,what you have to do is

<span style="font-family: Consolas, Monaco, monospace"></span>

[code lang="csharp"]

IDisposable webhost=WebApp.Start(hostAdress, appBuilder 
{
//application initialization code
});

[/code]

&nbsp;

Now to stop the webhost,we have to call dispose.Since we had this code inside a windows service,dispose was called when an exception occured or the service is stopped

[code lang="csharp"]

webhost.Dispose();

[/code]

Or rather the correct way to use OWinHost is using using block as explained <a href="https://docs.microsoft.com/en-us/aspnet/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api">here</a>

So iisexpress was not able to start the service because OWIN service had it started but not stopped before the process exited.]]></content:encoded>
    </item>
    <item>
      <title>Looking inside a .NET core process using windbg</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/looking-inside-a-net-core-process-using-windbg</link>
      <pubDate>Mon, 26 Mar 2018 04:19:24 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=375</guid>
      <description><![CDATA[In this blog post,we are going to look inside of a .NET Core process using windbg. .NET CORE process...]]></description>
      <content:encoded><![CDATA[In this blog post,we are going to look inside of a .NET Core process using windbg. .NET CORE process footprint is as minimal as possible so with this blog post,we are going to look at a simple .net core concole app running (simplest console app with bare minimum managed code) and check
<ul>
 	<li>How many .NET Objects it needs to run a console application</li>
 	<li>.NET dlls (managed) are loaded for a simple console application</li>
 	<li>What are the threads running (managed and unmanaged or native)</li>
 	<li>How does the callstack look like for .NET threads</li>
 	<li>How to look for a particular .NET object and dump it details</li>
</ul>
First lets start a simple .NET core console application .I already have the .NET core <a href="https://www.microsoft.com/net/download/windows">SDK </a>installed .Now create a simple console app and run
<pre>D:\PROJECTS\dotnet&gt;<strong>dotnet new console</strong>
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on D:\PROJECTS\dotnet\dotnet.csproj...
 Restoring packages for D:\PROJECTS\dotnet\dotnet.csproj...
 Generating MSBuild file D:\PROJECTS\dotnet\obj\dotnet.csproj.nuget.g.props.
 Generating MSBuild file D:\PROJECTS\dotnet\obj\dotnet.csproj.nuget.g.targets.
 Restore completed in 704.29 ms for D:\PROJECTS\dotnet\dotnet.csproj.

Restore succeeded.</pre>
After this ,We can do a build and run
<pre>D:\PROJECTS\dotnet&gt;<strong>dotnet build</strong>
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 57.84 ms for D:\PROJECTS\dotnet\dotnet.csproj.
 dotnet -&gt; D:\PROJECTS\dotnet\bin\Debug\netcoreapp2.0\dotnet.dll

Build succeeded.
 0 Warning(s)
 0 Error(s)

Time Elapsed 00:00:06.06</pre>
Finally running the app
<pre>D:\PROJECTS\dotnet&gt;dotnet run
Hello World!</pre>
We are going to use a windbg tool to do this,you can install <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/">debugging tools for windows</a> to get windbg .If you are doing a fresh installation, Make sure to install <strong class="">As a standalone tool set</strong>
<blockquote>If you want to download only Debugging Tools for Windows,<span> </span><a href="https://developer.microsoft.com/windows/downloads/windows-10-sdk">install the Windows SDK</a>, and, during the installation, select the<span> </span><strong>Debugging Tools for Windows</strong><span> </span>box and clear all the other boxes.</blockquote>
Once you have installed debugging tools,run windbg(make sure to run 64 bit version ). To inspect the dotnet process,we will make a small change to the code to add a Console.ReadLine(). This is done to make sure the process does not terminate as soon as it finishes

[csharp]
using System;

namespace dotnet
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(&quot;Hello World!&quot;);
Console.ReadLine();
}
}
}
[/csharp]

<ol>
 	<li>Run the console app using dotnet run command</li>
 	<li>When it successfully runs,it will launch console app and will not exit because of the Console.ReadLine() we added</li>
 	<li> Now,launch windg and attach to dotnet.exe process as shown below</li>
</ol>
<blockquote>make sure to launch windbg with the correct bitness(32 bit or 64 bit) .You have to match the bitness of the process you are going to debug with the windbg</blockquote>
Now from the windbg menu,choose <strong>Attach to a Process( press F6) </strong>and find dotnet.exe running.<a href="https://msdnshared.blob.core.windows.net/media/2018/03/dotnet-windbg-attach.png"><img src="https://msdnshared.blob.core.windows.net/media/2018/03/dotnet-windbg-attach.png" alt="" width="385" height="528" class="size-full wp-image-385 aligncenter" /></a>

Once you have attached,you should see following
<pre>Microsoft (R) Windows Debugger Version 6.12.0002.633 AMD64
 Copyright (c) Microsoft Corporation. All rights reserved.

*** wait with pending attach
 Symbol search path is: srv*c:\symcache*http://msdl.microsoft.com/download/symbols
 Executable search path is:
 ModLoad: 00000001`3fdc0000 00000001`3fde7000 C:\Program Files\dotnet\dotnet.exe
 ModLoad: 00000000`76e80000 00000000`7702a000 C:\windows\SYSTEM32\ntdll.dll
 ModLoad: 00000000`76c60000 00000000`76d7f000 C:\windows\system32\kernel32.dll
 ModLoad: 000007fe`fcbf0000 000007fe`fcc5a000 C:\windows\system32\KERNELBASE.dll
 ModLoad: 00000000`74860000 00000000`748ee000 C:\windows\System32\SYSFER.DLL
 ModLoad: 000007fe`fdb20000 000007fe`fdbfb000 C:\windows\system32\ADVAPI32.dll
 ModLoad: 000007fe`fea80000 000007fe`feb1f000 C:\windows\system32\msvcrt.dll
 ModLoad: 000007fe`fd310000 000007fe`fd32f000 C:\windows\SYSTEM32\sechost.dll
 ModLoad: 000007fe`feff0000 000007fe`ff11d000 C:\windows\system32\RPCRT4.dll
 ModLoad: 000007fe`f5430000 000007fe`f5434000 C:\windows\system32\api-ms-win-crt-runtime-l1-1-0.dll
 ModLoad: 000007fe`dee30000 000007fe`def24000 C:\windows\system32\ucrtbase.DLL
 ModLoad: 000007fe`f5420000 000007fe`f5423000 C:\windows\system32\api-ms-win-core-timezone-l1-1-0.dll
 ModLoad: 000007fe`f4410000 000007fe`f4413000 C:\windows\system32\api-ms-win-core-file-l2-1-0.dll
 ModLoad: 000007fe`f4400000 000007fe`f4403000 C:\windows\system32\api-ms-win-core-localization-l1-2-0.dll
 ModLoad: 000007fe`fba40000 000007fe`fba43000 C:\windows\system32\api-ms-win-core-synch-l1-2-0.dll
 ModLoad: 000007fe`f4360000 000007fe`f4363000 C:\windows\system32\api-ms-win-core-processthreads-l1-1-1.dll
 ModLoad: 000007fe`f4350000 000007fe`f4353000 C:\windows\system32\api-ms-win-core-file-l1-2-0.dll
 ModLoad: 000007fe`ea900000 000007fe`ea905000 C:\windows\system32\api-ms-win-crt-math-l1-1-0.dll
 ModLoad: 000007fe`f4100000 000007fe`f4103000 C:\windows\system32\api-ms-win-crt-heap-l1-1-0.dll
 ModLoad: 000007fe`ee870000 000007fe`ee874000 C:\windows\system32\api-ms-win-crt-convert-l1-1-0.dll
 ModLoad: 000007fe`f40f0000 000007fe`f40f4000 C:\windows\system32\api-ms-win-crt-stdio-l1-1-0.dll
 ModLoad: 000007fe`f42f0000 000007fe`f42f4000 C:\windows\system32\api-ms-win-crt-string-l1-1-0.dll
 ModLoad: 000007fe`ee620000 000007fe`ee623000 C:\windows\system32\api-ms-win-crt-locale-l1-1-0.dll
 ModLoad: 000007fe`ea8f0000 000007fe`ea8f5000 C:\windows\system32\api-ms-win-crt-multibyte-l1-1-0.dll
 ModLoad: 000007fe`d6b00000 000007fe`d6b51000 C:\Program Files\dotnet\host\fxr\2.0.5\hostfxr.dll
 ModLoad: 000007fe`e77e0000 000007fe`e77e3000 C:\windows\system32\api-ms-win-crt-filesystem-l1-1-0.dll
 ModLoad: 000007fe`d6a70000 000007fe`d6af9000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\hostpolicy.dll
 ModLoad: 000007fe`d1070000 000007fe`d15ba000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\coreclr.dll
 ModLoad: 000007fe`fd640000 000007fe`fd83c000 C:\windows\system32\ole32.dll
 ModLoad: 000007fe`ff120000 000007fe`ff187000 C:\windows\system32\GDI32.dll
 ModLoad: 00000000`76d80000 00000000`76e7a000 C:\windows\system32\USER32.dll
 ModLoad: 000007fe`fd3d0000 000007fe`fd3de000 C:\windows\system32\LPK.dll
 ModLoad: 000007fe`fd3e0000 000007fe`fd4ab000 C:\windows\system32\USP10.dll
 ModLoad: 000007fe`fe990000 000007fe`fea6a000 C:\windows\system32\OLEAUT32.dll
 ModLoad: 000007fe`fbc20000 000007fe`fbc2c000 C:\windows\system32\VERSION.dll
 ModLoad: 000007fe`fd290000 000007fe`fd301000 C:\windows\system32\SHLWAPI.dll
 ModLoad: 000007fe`fc4b0000 000007fe`fc4d2000 C:\windows\system32\bcrypt.dll
 ModLoad: 000007fe`de290000 000007fe`de293000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\api-ms-win-crt-utility-l1-1-0.dll
 ModLoad: 000007fe`ddb80000 000007fe`ddb83000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\api-ms-win-crt-time-l1-1-0.dll
 ModLoad: 000007fe`fd260000 000007fe`fd28e000 C:\windows\system32\IMM32.DLL
 ModLoad: 000007fe`fd4b0000 000007fe`fd5b9000 C:\windows\system32\MSCTF.dll
 ModLoad: 000007fe`c5330000 000007fe`c5e84000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\System.Private.CoreLib.dll
 ModLoad: 000007fe`f3ae0000 000007fe`f3b4f000 C:\windows\SYSTEM32\MSCOREE.DLL
 ModLoad: 00000000`00300000 00000000`00308000 D:\PROJECTS\dotnet\bin\Debug\netcoreapp2.0\dotnet.dll
 ModLoad: 000007fe`ddb70000 000007fe`ddb7d000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\System.Runtime.dll
 ModLoad: 000007fe`d1bb0000 000007fe`d1cbb000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\clrjit.dll
 ModLoad: 000007fe`d0e60000 000007fe`d0e87000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\System.Console.dll
 ModLoad: 000007fe`dc4e0000 000007fe`dc4f3000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\System.Threading.dll
 ModLoad: 000007fe`d1cc0000 000007fe`d1d34000 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\System.Runtime.Extensions.dll
 (6018.7540): Break instruction exception - code 80000003 (first chance)</pre>
<strong>This means that windbg is successfully attached to our dotnet core process.</strong>

Now we can run some commands in windbg to get some internal details about
<h3>Getting the active threads running</h3>
For this run a simple command <strong>~</strong> in windbg
<pre>0:000&gt; ~
 . 0 Id: 6018.1244 Suspend: 1 Teb: 000007ff`fffde000 Unfrozen
 1 Id: 6018.67e8 Suspend: 1 Teb: 000007ff`fffdc000 Unfrozen
 2 Id: 6018.550 Suspend: 1 Teb: 000007ff`fffda000 Unfrozen
 # 3 Id: 6018.7540 Suspend: 1 Teb: 000007ff`fffd8000 Unfrozen</pre>
tilde(~) simply lists all the threads running with the threadid.There are many variations you can do
<ul>
 	<li>~*  - shows little more information like the top method currently executing .* means all the threads</li>
 	<li><strong>~*k</strong> - shows all the threads along with the stack</li>
 	<li>~&lt;threadnum&gt;s - will switch to thread number threadnum you specifiy
<ul>
 	<li>
<pre>e.g. 0:000&gt; ~1s
 ntdll!ZwWaitForMultipleObjects+0xa:
 00000000`76ecc2ea c3 ret
 0:001&gt;</pre>
</li>
</ul>
</li>
</ul>
<pre>0:001&gt; ~*k

0 Id: 6018.1244 Suspend: 1 Teb: 000007ff`fffde000 Unfrozen
 Child-SP RetAddr Call Site
 00000000`001adc48 00000000`76c818e8 ntdll!NtRequestWaitReplyPort+0xa
 00000000`001adc50 00000000`76cb57f1 kernel32!ConsoleClientCallServer+0x54
 00000000`001adc80 00000000`76cca9f2 kernel32!ReadConsoleInternal+0x1f1
 00000000`001addd0 00000000`76c97e64 kernel32!ReadConsoleA+0xb2
 00000000`001adeb0 000007fe`716d147f kernel32!TlsGetValue+0x81fe
 00000000`001adef0 000007fe`d0e78f65 0x7fe`716d147f
 00000000`001adfb0 000007fe`d0e78db3 System_Console+0x18f65
 00000000`001ae010 000007fe`d1d0dc6d System_Console+0x18db3
 00000000`001ae080 000007fe`d1d0e04a System_Runtime_Extensions+0x4dc6d
 00000000`001ae0d0 000007fe`d0e7d517 System_Runtime_Extensions+0x4e04a
 00000000`001ae120 000007fe`d0e752fa System_Console+0x1d517
 00000000`001ae170 000007fe`716d04b6 System_Console+0x152fa
 00000000`001ae1a0 000007fe`d11a35d3 0x7fe`716d04b6
 00000000`001ae1e0 000007fe`d10cd9bf coreclr!CallDescrWorkerInternal+0x83 [E:\A\_work\1791\s\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101]
 00000000`001ae220 000007fe`d1193ef7 coreclr!MethodDescCallSite::CallTargetWorker+0x17b [e:\a\_work\1791\s\src\vm\callhelpers.cpp @ 653]
 00000000`001ae370 000007fe`d108b195 coreclr!RunMain+0x17f [e:\a\_work\1791\s\src\vm\assembly.cpp @ 1849]
 00000000`001ae5d0 000007fe`d112ba29 coreclr!Assembly::ExecuteMainMethod+0xb5 [e:\a\_work\1791\s\src\vm\assembly.cpp @ 1944]
 00000000`001ae890 000007fe`d112d9ce coreclr!CorHost2::ExecuteAssembly+0x149 [e:\a\_work\1791\s\src\vm\corhost.cpp @ 502]
 00000000`001ae960 000007fe`d6a8e8b9 coreclr!coreclr_execute_assembly+0xde [e:\a\_work\1791\s\src\dlls\mscoree\unixinterface.cpp @ 407]
 00000000`001ae9f0 000007fe`d6a8ee44 hostpolicy!run+0xdb9
 00000000`001af0c0 000007fe`d6b19b05 hostpolicy!corehost_main+0x164
 00000000`001af240 000007fe`d6b1f42b hostfxr!execute_app+0x1f5
 00000000`001af310 000007fe`d6b1e819 hostfxr!fx_muxer_t::read_config_and_execute+0x94b
 00000000`001af9b0 000007fe`d6b1cc8d hostfxr!fx_muxer_t::parse_args_and_execute+0x409
 00000000`001afb40 00000001`3fdc9abc hostfxr!fx_muxer_t::execute+0x22d
 00000000`001afcd0 00000001`3fdce099 dotnet!wmain+0x46c
 00000000`001afde0 00000000`76c759cd dotnet!__scrt_common_main_seh+0x11d [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl @ 253]
 00000000`001afe20 00000000`76eaa561 kernel32!BaseThreadInitThunk+0xd
 00000000`001afe50 00000000`00000000 ntdll!RtlUserThreadStart+0x1d

1 Id: 6018.67e8 Suspend: 1 Teb: 000007ff`fffdc000 Unfrozen
 Child-SP RetAddr Call Site
 00000000`0232f648 000007fe`fcbf1430 ntdll!ZwWaitForMultipleObjects+0xa
 00000000`0232f650 00000000`76c816e3 KERNELBASE!WaitForMultipleObjectsEx+0xe8
 00000000`0232f750 000007fe`d118b36a kernel32!WaitForMultipleObjectsExImplementation+0xb3
 00000000`0232f7e0 000007fe`d118b44e coreclr!DebuggerRCThread::MainLoop+0xce [e:\a\_work\1791\s\src\debug\ee\rcthread.cpp @ 1241]
 00000000`0232f8a0 000007fe`d118ae8a coreclr!DebuggerRCThread::ThreadProc+0xd2 [e:\a\_work\1791\s\src\debug\ee\rcthread.cpp @ 1042]
 00000000`0232f8f0 00000000`76c759cd coreclr!DebuggerRCThread::ThreadProcStatic+0x1a [e:\a\_work\1791\s\src\debug\ee\rcthread.cpp @ 1642]
 00000000`0232f920 00000000`76eaa561 kernel32!BaseThreadInitThunk+0xd
 00000000`0232f950 00000000`00000000 ntdll!RtlUserThreadStart+0x1d

2 Id: 6018.550 Suspend: 1 Teb: 000007ff`fffda000 Unfrozen
 Child-SP RetAddr Call Site
 00000000`1a94f5f8 000007fe`fcbf1430 ntdll!ZwWaitForMultipleObjects+0xa
 00000000`1a94f600 00000000`76c816e3 KERNELBASE!WaitForMultipleObjectsEx+0xe8
 00000000`1a94f700 000007fe`d1176361 kernel32!WaitForMultipleObjectsExImplementation+0xb3
 00000000`1a94f790 000007fe`d1175de2 coreclr!FinalizerThread::WaitForFinalizerEvent+0x85 [e:\a\_work\1791\s\src\vm\finalizerthread.cpp @ 469]
 00000000`1a94f7d0 000007fe`d10cd66b coreclr!FinalizerThread::FinalizerThreadWorker+0x62 [e:\a\_work\1791\s\src\vm\finalizerthread.cpp @ 587]
 00000000`1a94f830 000007fe`d10cd586 coreclr!ManagedThreadBase_DispatchInner+0x43 [e:\a\_work\1791\s\src\vm\threads.cpp @ 9204]
 00000000`1a94f870 000007fe`d10cd498 coreclr!ManagedThreadBase_DispatchMiddle+0x82 [e:\a\_work\1791\s\src\vm\threads.cpp @ 9253]
 00000000`1a94f9d0 000007fe`d117587c coreclr!ManagedThreadBase_DispatchOuter+0xb4 [e:\a\_work\1791\s\src\vm\threads.cpp @ 9492]
 00000000`1a94fa80 000007fe`d11773fb coreclr!FinalizerThread::FinalizerThreadStart+0x9c [e:\a\_work\1791\s\src\vm\finalizerthread.cpp @ 774]
 00000000`1a94fb20 00000000`76c759cd coreclr!Thread::intermediateThreadProc+0x8b [e:\a\_work\1791\s\src\vm\threads.cpp @ 2594]
 00000000`1a94fbe0 00000000`76eaa561 kernel32!BaseThreadInitThunk+0xd
 00000000`1a94fc10 00000000`00000000 ntdll!RtlUserThreadStart+0x1d

# 3 Id: 6018.7540 Suspend: 1 Teb: 000007ff`fffd8000 Unfrozen
 Child-SP RetAddr Call Site
 00000000`1ac7fc28 00000000`76f72e08 ntdll!DbgBreakPoint
 00000000`1ac7fc30 00000000`76c759cd ntdll!DbgUiRemoteBreakin+0x38
 00000000`1ac7fc60 00000000`76eaa561 kernel32!BaseThreadInitThunk+0xd
 00000000`1ac7fc90 00000000`00000000 ntdll!RtlUserThreadStart+0x1d</pre>
We see 4 threads running in idle state and callstacks of the threads.But these windbg commands only shows native stacks and does not show managed threads or stacks.To make windbg understand about CLR and managed threads, we have to <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-engine-and-extension-apis">windbg debugging extension dlls </a> .In this case we are going to use a dll called <a href="https://docs.microsoft.com/en-us/dotnet/framework/tools/sos-dll-sos-debugging-extension">SOS</a>

We have SOS.dll for every version and bitness of .NET framework (.NET 1.1,2.0,4.0 etc) .So for .NET core process debugging we need to use .NET Core's sos.dll . And the good part is that sos.dll is shipped with the dotnet and you will find it on

<strong>64bit: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\sos.dll </strong>

<strong>32bit: C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\2.0.5\sos.dll</strong>

Now to load any extension to windbg,we have to use .load command
<pre>.load C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\sos</pre>
You can also use alternate command .loadby
<pre>0:001&gt; .loadby sos coreclr</pre>
What this does is it will automatically find the sos path and load from the already existing dll  coreclr which is loaded into the dotnet.exe process. Once it is loaded,you can get all the commands using help
<pre>0:001&gt; !help
 -------------------------------------------------------------------------------
 SOS is a debugger extension DLL designed to aid in the debugging of managed
 programs. Functions are listed by category, then roughly in order of
 importance. Shortcut names for popular functions are listed in parenthesis.
 Type "!help &lt;functionname&gt;" for detailed info on that function.

Object Inspection Examining code and stacks
 ----------------------------- -----------------------------
 DumpObj (do) Threads
 DumpArray (da) ThreadState
 DumpStackObjects (dso) IP2MD
 DumpHeap U
 DumpVC DumpStack
 GCRoot EEStack
 ObjSize CLRStack
 FinalizeQueue GCInfo
 PrintException (pe) EHInfo
 TraverseHeap BPMD
 COMState

Examining CLR data structures Diagnostic Utilities
 ----------------------------- -----------------------------
 DumpDomain VerifyHeap
 EEHeap VerifyObj
 Name2EE FindRoots
 SyncBlk HeapStat
 DumpMT GCWhere
 DumpClass ListNearObj (lno)
 DumpMD GCHandles
 Token2EE GCHandleLeaks
 EEVersion FinalizeQueue (fq)
 DumpModule FindAppDomain
 ThreadPool SaveModule
 DumpAssembly ProcInfo
 DumpSigElem StopOnException (soe)
 DumpRuntimeTypes DumpLog
 DumpSig VMMap
 RCWCleanupList VMStat
 DumpIL MinidumpMode
 DumpRCW AnalyzeOOM (ao)
 DumpCCW

Examining the GC history Other
 ----------------------------- -----------------------------
 HistInit FAQ
 HistRoot
 HistObj
 HistObjFind
 HistClear

</pre>
don't worry about all these commands ,we are going to use a handful of them .mainly !threads !CLRStack and !dumpheap .
<blockquote>Please note that all extension commands will start with ! .So all commands inside sos.dll we have to use !threads ,!clrstack etc.</blockquote>
&nbsp;
<h3>Getting managed threads and stacks</h3>
<pre>0:001&gt; !threads
 ThreadCount: 2
 UnstartedThread: 0
 BackgroundThread: 1
 PendingThread: 0
 DeadThread: 0
 Hosted Runtime: no
 Lock
 ID OSID ThreadOBJ State GC Mode GC Alloc Context Domain Count Apt Exception
 0 1 1244 00000000005cb900 20020 Preemptive 0000000002355278:00000000023561C0 0000000000433400 1 Ukn
 2 2 550 00000000005f1fb0 21220 Preemptive 0000000000000000:0000000000000000 0000000000433400 0 Ukn (Finalizer)

Once you see manageed thread,you can switch to that thread by ~&lt;threadnumber&gt;s

to switch to first thread ~ss

0:001&gt; ~0s
 ntdll!NtRequestWaitReplyPort+0xa:
 00000000`76ecbf5a c3 ret
 0:000&gt; !clrstack
 OS Thread Id: 0x1244 (0)
 Child SP IP Call Site
 00000000001adf20 0000000076ecbf5a [InlinedCallFrame: 00000000001adf20] Interop+Kernel32.ReadFile(IntPtr, Byte*, Int32, Int32 ByRef, IntPtr)
 00000000001adf20 000007fe716d147f [InlinedCallFrame: 00000000001adf20] Interop+Kernel32.ReadFile(IntPtr, Byte*, Int32, Int32 ByRef, IntPtr)
 00000000001adef0 000007fe716d147f DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, Byte*, Int32, Int32 ByRef, IntPtr)
 00000000001adfb0 000007fed0e78f65 System.ConsolePal+WindowsConsoleStream.ReadFileNative(IntPtr, Byte[], Int32, Int32, Boolean, Int32 ByRef, Boolean) [E:\A\_work\1439\s\corefx\src\System.Console\src\System\ConsolePal.Windows.cs @ 1170]
 00000000001ae010 000007fed0e78db3 System.ConsolePal+WindowsConsoleStream.Read(Byte[], Int32, Int32) [E:\A\_work\1439\s\corefx\src\System.Console\src\System\ConsolePal.Windows.cs @ 1121]
 00000000001ae080 000007fed1d0dc6d System.IO.StreamReader.ReadBuffer() [E:\A\_work\1439\s\corefx\src\System.Runtime.Extensions\src\System\IO\StreamReader.cs @ 627]
 00000000001ae0d0 000007fed1d0e04a System.IO.StreamReader.ReadLine() [E:\A\_work\1439\s\corefx\src\System.Runtime.Extensions\src\System\IO\StreamReader.cs @ 802]
 00000000001ae120 000007fed0e7d517 System.IO.SyncTextReader.ReadLine() [E:\A\_work\1439\s\corefx\src\System.Console\src\System\IO\SyncTextReader.cs @ 78]
 00000000001ae170 000007fed0e752fa System.Console.ReadLine() [E:\A\_work\1439\s\corefx\src\System.Console\src\System\Console.cs @ 474]
 00000000001ae1a0 000007fe716d04b6 dotnet.Program.Main(System.String[]) [D:\PROJECTS\dotnet\Program.cs @ 10]
 00000000001ae418 000007fed11a35d3 [GCFrame: 00000000001ae418]
 00000000001ae8f8 000007fed11a35d3 [GCFrame: 00000000001ae8f8]</pre>
Now We can check how the native stack will look like by running k

0:000&gt; k
Child-SP RetAddr Call Site
00000000`001adc48 00000000`76c818e8 ntdll!NtRequestWaitReplyPort+0xa
00000000`001adc50 00000000`76cb57f1 kernel32!ConsoleClientCallServer+0x54
00000000`001adc80 00000000`76cca9f2 kernel32!ReadConsoleInternal+0x1f1
00000000`001addd0 00000000`76c97e64 kernel32!ReadConsoleA+0xb2
00000000`001adeb0 000007fe`716d147f kernel32!TlsGetValue+0x81fe
00000000`001adef0 000007fe`d0e78f65 0x7fe`716d147f
00000000`001adfb0 000007fe`d0e78db3 System_Console+0x18f65
00000000`001ae010 000007fe`d1d0dc6d System_Console+0x18db3
00000000`001ae080 000007fe`d1d0e04a System_Runtime_Extensions+0x4dc6d
00000000`001ae0d0 000007fe`d0e7d517 System_Runtime_Extensions+0x4e04a
00000000`001ae120 000007fe`d0e752fa System_Console+0x1d517
00000000`001ae170 000007fe`716d04b6 System_Console+0x152fa
00000000`001ae1a0 000007fe`d11a35d3 0x7fe`716d04b6
00000000`001ae1e0 000007fe`d10cd9bf coreclr!CallDescrWorkerInternal+0x83 [E:\A\_work\1791\s\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101]
00000000`001ae220 000007fe`d1193ef7 coreclr!MethodDescCallSite::CallTargetWorker+0x17b [e:\a\_work\1791\s\src\vm\callhelpers.cpp @ 653]
00000000`001ae370 000007fe`d108b195 coreclr!RunMain+0x17f [e:\a\_work\1791\s\src\vm\assembly.cpp @ 1849]
00000000`001ae5d0 000007fe`d112ba29 coreclr!Assembly::ExecuteMainMethod+0xb5 [e:\a\_work\1791\s\src\vm\assembly.cpp @ 1944]
00000000`001ae890 000007fe`d112d9ce coreclr!CorHost2::ExecuteAssembly+0x149 [e:\a\_work\1791\s\src\vm\corhost.cpp @ 502]
00000000`001ae960 000007fe`d6a8e8b9 coreclr!coreclr_execute_assembly+0xde [e:\a\_work\1791\s\src\dlls\mscoree\unixinterface.cpp @ 407]
00000000`001ae9f0 000007fe`d6a8ee44 hostpolicy!run+0xdb9
00000000`001af0c0 000007fe`d6b19b05 hostpolicy!corehost_main+0x164
<strong>00000000`001af240 000007fe`d6b1f42b hostfxr!execute_app+0x1f5</strong>
00000000`001af310 000007fe`d6b1e819 hostfxr!fx_muxer_t::read_config_and_execute+0x94b
00000000`001af9b0 000007fe`d6b1cc8d hostfxr!fx_muxer_t::parse_args_and_execute+0x409
00000000`001afb40 00000001`3fdc9abc hostfxr!fx_muxer_t::execute+0x22d
00000000`001afcd0 00000001`3fdce099 dotnet!wmain+0x46c
00000000`001afde0 00000000`76c759cd dotnet!__scrt_common_main_seh+0x11d [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl @ 253]
00000000`001afe20 00000000`76eaa561 kernel32!BaseThreadInitThunk+0xd
00000000`001afe50 00000000`00000000 ntdll!RtlUserThreadStart+0x1d

&nbsp;

As you see the managed stack and native stack look different this is because CLR abstracts away many details from the actual machine level execution.
<blockquote>hostfxr!execute_app method executes your .NET code. Once it loads coreclr ,everything happens is on .NET terms . coreclr loads the .NET dlls and all the reference dlls and execute your code</blockquote>
As you see there are two managed threads running (from the output of !threads command),lets see what the other thread is doing
<pre>0:000&gt; ~2s
 ntdll!ZwWaitForMultipleObjects+0xa:
 00000000`76ecc2ea c3 ret
 0:002&gt; !clrstack
 OS Thread Id: 0x550 (2)
 Child SP IP Call Site
 000000001a94fa00 0000000076ecc2ea [DebuggerU2MCatchHandlerFrame: 000000001a94fa00]</pre>
We really do not see any manage callstack although it is managed thread.So let's see what it actually is by looking at the native callstack
<pre>0:002&gt; k
 Child-SP RetAddr Call Site
 00000000`1a94f5f8 000007fe`fcbf1430 ntdll!ZwWaitForMultipleObjects+0xa
 00000000`1a94f600 00000000`76c816e3 KERNELBASE!WaitForMultipleObjectsEx+0xe8
 00000000`1a94f700 000007fe`d1176361 kernel32!WaitForMultipleObjectsExImplementation+0xb3
 00000000`1a94f790 000007fe`d1175de2 coreclr!FinalizerThread::WaitForFinalizerEvent+0x85 [e:\a\_work\1791\s\src\vm\finalizerthread.cpp @ 469]
 00000000`1a94f7d0 000007fe`d10cd66b coreclr!FinalizerThread::FinalizerThreadWorker+0x62 [e:\a\_work\1791\s\src\vm\finalizerthread.cpp @ 587]
 00000000`1a94f830 000007fe`d10cd586 coreclr!ManagedThreadBase_DispatchInner+0x43 [e:\a\_work\1791\s\src\vm\threads.cpp @ 9204]
 00000000`1a94f870 000007fe`d10cd498 coreclr!ManagedThreadBase_DispatchMiddle+0x82 [e:\a\_work\1791\s\src\vm\threads.cpp @ 9253]
 00000000`1a94f9d0 000007fe`d117587c coreclr!ManagedThreadBase_DispatchOuter+0xb4 [e:\a\_work\1791\s\src\vm\threads.cpp @ 9492]
 00000000`1a94fa80 000007fe`d11773fb coreclr!FinalizerThread::FinalizerThreadStart+0x9c [e:\a\_work\1791\s\src\vm\finalizerthread.cpp @ 774]
 00000000`1a94fb20 00000000`76c759cd coreclr!Thread::intermediateThreadProc+0x8b [e:\a\_work\1791\s\src\vm\threads.cpp @ 2594]
 00000000`1a94fbe0 00000000`76eaa561 kernel32!BaseThreadInitThunk+0xd
 00000000`1a94fc10 00000000`00000000 ntdll!RtlUserThreadStart+0x1d</pre>
As you see from the stack,it is finalizer thread

Now let's move on to  .NET obejcts in the heap.For this ,we will use !<strong>dumpheap</strong> .
<pre>0:002&gt; !dumpheap
 Statistics:
 MT Count TotalSize Class Name
 000007fec5cd6c68 1 24 System.Collections.Generic.GenericEqualityComparer`1[[System.Char, System.Private.CoreLib]]
 000007fec5ccb060 1 24 System.Environment+&lt;&gt;c
 000007fec5cc5130 1 24 System.Collections.Generic.GenericEqualityComparer`1[[System.String, System.Private.CoreLib]]
 000007fec5cbe1e0 1 24 System.Reflection.Missing
 000007fec5cb8c58 1 24 System.Security.Policy.ApplicationTrust
 000007fec5cb6e98 1 24 System.Diagnostics.Tracing.EtwEventProvider
 000007fec5cb4168 1 24 System.OrdinalIgnoreCaseComparer
 000007fec5cb4068 1 24 System.OrdinalCaseSensitiveComparer
 000007fec5cb1bd8 1 24 System.SharedStatics
 000007fec5ca00f8 1 24 System.WeakReference
 000007fec5c91228 1 24 System.Collections.Generic.NonRandomizedStringEqualityComparer
 000007fec5c88388 1 24 System.Boolean
 000007fec5c53388 1 24 System.Attribute[]
 000007fec537f038 1 24 System.Collections.Generic.Dictionary`2+KeyCollection[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]]
 000007fe7157cdb8 1 24 System.IO.SyncTextReader
 000007fe715790d8 1 24 System.Console+&lt;&gt;c
 000007fe71566fe0 1 24 System.Collections.Generic.ObjectEqualityComparer`1[[System.RuntimeType, System.Private.CoreLib]]
 000007fec5c62708 1 26 System.Globalization.CalendarId[]
 000007fec5c53260 1 31 System.Boolean[]
 000007fec5ce2358 1 32 System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1[[System.Char, System.Private.CoreLib]]
 000007fec5ccc430 1 32 System.IO.Stream+NullStream
 000007fec5c9d0a8 1 32 System.Diagnostics.Tracing.ActivityTracker
 000007fec5c8da20 1 32 System.Guid
 000007fec5c59028 1 32 System.Reflection.RuntimePropertyInfo[]
 000007fec5c98ef0 1 40 System.Collections.Generic.List`1+Enumerator[[System.String, System.Private.CoreLib]]
 000007fec5c54658 1 40 System.WeakReference[]
 000007fec5378e28 1 40 System.Collections.Generic.List`1[[System.WeakReference, System.Private.CoreLib]]
 000007fec5377168 1 40 System.Collections.Generic.List`1[[System.String, System.Private.CoreLib]]
 000007fe7157bc50 1 40 System.IO.TextWriter+NullTextWriter
 000007fe715799e0 1 40 Interop+InputRecord
 000007fe71567680 1 40 System.Reflection.CerHashtable`2+Table[[System.String, System.Private.CoreLib],[System.Reflection.RuntimePropertyInfo[], System.Private.CoreLib]]
 000007fe715668c0 1 40 System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]]
 000007fec5cce310 1 48 System.Text.Encoding+DefaultDecoder
 000007fec5c59768 2 48 System.Reflection.ParameterInfo[]
 000007fe7157c0f8 1 48 System.IO.SyncTextWriter
 000007fe7157be68 1 48 System.Text.OSEncoder
 000007fec5c92158 1 56 System.RuntimeType+RuntimeTypeCache+MemberInfoCache`1[[System.Reflection.RuntimePropertyInfo, System.Private.CoreLib]]
 000007fec5c91d58 1 56 System.RuntimeType+RuntimeTypeCache+MemberInfoCache`1[[System.Reflection.RuntimeMethodInfo, System.Private.CoreLib]]
 000007fec5c8f3e8 1 56 System.Reflection.RuntimeAssembly
 000007fec5c88d10 1 56 System.Globalization.CompareInfo
 000007fec5cb3f58 2 64 System.CultureAwareComparer
 000007fec5ca0e78 2 64 System.LazyHelper
 000007fec5c963c8 1 64 System.Reflection.RuntimeModule
 000007fec5c49988 1 64 Microsoft.Win32.UnsafeNativeMethods+ManifestEtw+EtwEnableCallback
 000007fe7157c6e0 1 64 System.Func`1[[System.IO.TextReader, System.Runtime.Extensions]]
 000007fe71579188 1 64 System.Func`1[[System.IO.TextWriter, System.Runtime.Extensions]]
 000007fe71567188 2 64 System.Diagnostics.Tracing.EventSourceAttribute[]
 000007fec5ca64e0 3 72 System.IntPtr
 000007fec5cb7070 2 80 System.Diagnostics.Tracing.EventSourceAttribute
 000007fec5c9d478 2 80 System.Lazy`1[[System.Boolean, System.Private.CoreLib]]
 000007fec537a308 1 80 System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Globalization.CultureData, System.Private.CoreLib]]
 000007fec53799f0 1 80 System.Collections.Generic.Dictionary`2[[System.RuntimeType, System.Private.CoreLib],[System.RuntimeType, System.Private.CoreLib]]
 000007fe715677c8 1 80 System.Reflection.RuntimePropertyInfo[][]
 000007fec5cce920 2 96 System.Text.UTF8Encoding+UTF8EncodingSealed
 000007fec5ccb5e8 1 96 System.Diagnostics.Tracing.EventSource+OverideEventProvider
 000007fec5c587e0 2 96 System.Reflection.CustomAttributeRecord[]
 000007fec5c54280 3 96 System.IntPtr[]
 000007fe7157cbc0 1 96 System.IO.StreamReader
 000007fe715662b8 1 96 System.Collections.Generic.Dictionary`2+Entry[[System.String, System.Private.CoreLib],[System.Globalization.CultureData, System.Private.CoreLib]][]
 000007fec5c92b58 1 104 System.Reflection.RuntimePropertyInfo
 000007fe7157b9d0 1 104 System.IO.StreamWriter
 000007fec5cc38f0 2 112 System.Text.UnicodeEncoding
 000007fe7157b4b8 2 112 System.Text.ConsoleEncoding
 000007fe71579e10 2 112 System.ConsolePal+WindowsConsoleStream
 000007fec5c590b8 3 120 System.Reflection.RuntimeMethodInfo[]
 000007fec5c9ba08 4 128 System.Text.DecoderReplacementFallback
 000007fec5c9b9a8 4 128 System.Text.EncoderReplacementFallback
 000007fec5c8b930 2 128 System.Globalization.TextInfo
 000007fec5c44c10 2 128 System.Func`1[[System.Boolean, System.Private.CoreLib]]
 000007fe7157b0a0 2 128 System.Text.OSEncoding
 000007fe71567c28 2 128 System.Func`1[[System.Text.Encoding, System.Private.CoreLib]]
 000007fec5cb81b0 1 152 System.Buffers.ArrayPoolEventSource
 000007fec5cb3db8 1 152 System.StackOverflowException
 000007fec5cb2f68 1 152 System.ExecutionEngineException
 000007fec5ca5ba0 1 152 System.OutOfMemoryException
 000007fec5c8a718 1 152 System.Exception
 000007fec5c88340 1 152 System.AppDomain
 000007fec5cc2cb8 4 160 System.Text.InternalEncoderBestFitFallback
 000007fec5c90d98 1 160 System.Globalization.CalendarData
 000007fec5c6d230 1 160 System.Char[][]
 000007fec5c55b50 1 160 System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1+PerCoreLockedStacks[[System.Char, System.Private.CoreLib]][]
 000007fec5c8af30 7 168 System.Object
 000007fec5cb19e8 2 176 System.RuntimeMethodInfoStub
 0000000000483380 7 186 Free
 000007fec5cc2770 4 192 System.Text.InternalDecoderBestFitFallback
 000007fec5c8b5a0 4 192 System.Text.StringBuilder
 000007fec5c2fba8 3 192 System.Reflection.MemberFilter
 000007fec5c923c0 2 208 System.Reflection.RuntimeMethodInfo
 000007fec5c61260 1 208 System.Globalization.CalendarData[]
 000007fec5c54ec8 7 216 System.Type[]
 000007fec5c96bd8 3 240 System.Signature
 000007fe71566b68 1 288 System.Collections.Generic.Dictionary`2+Entry[[System.RuntimeType, System.Private.CoreLib],[System.RuntimeType, System.Private.CoreLib]][]
 000007fec5cb9c80 2 304 System.Threading.ThreadAbortException
 000007fec5c91cb8 2 304 System.RuntimeType+RuntimeTypeCache
 000007fec5c9c190 3 312 System.AppDomainSetup
 000007fec5379db0 4 320 System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]]
 000007fec5c88be8 3 336 System.Globalization.CultureInfo
 000007fec5c546f8 1 364 System.UInt32[]
 000007fec5c53e28 10 384 System.RuntimeType[]
 000007fec5c54158 13 940 System.Int32[]
 000007fec5c8b498 2 944 System.Globalization.CultureData
 000007fe71566648 6 1008 System.Collections.Generic.Dictionary`2+Entry[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]][]
 000007fec5c8dd70 36 1440 System.RuntimeType
 000007fec5c528e8 24 1728 System.String[]
 000007fec5c53050 7 4148 System.Byte[]
 000007fec5c52ca8 10 17776 System.Object[]
 000007fec5c567e0 14 31538 System.Char[]
 000007fec5c87be8 320 94632 System.String</pre>
&nbsp;

We see that there are around 600 objects. We can get more details about !dumpheap by getting the help with help command
<pre>0:002&gt; !help  dumpheap0:002&gt; !help  dumpheap-------------------------------------------------------------------------------!DumpHeap [-stat]           [-strings]           [-short]          [-min &lt;size&gt;]           [-max &lt;size&gt;]           [-live]          [-dead]          [-thinlock]           [-startAtLowerBound]          [-mt &lt;MethodTable address&gt;]           [-type &lt;partial type name&gt;]           [start [end]]
!DumpHeap is a powerful command that traverses the garbage collected heap, collection statistics about objects. With it's various options, it can look forparticular types, restrict to a range, or look for ThinLocks (see !SyncBlk documentation). Finally, it will provide a warning if it detects excessive fragmentation in the GC heap. 
When called without options, the output is first a list of objects in the heap,followed by a report listing all the types found, their size and number:
 0:000&gt; !dumpheap Address       MT     Size 00a71000 0015cde8       12 Free 00a7100c 0015cde8       12 Free 00a71018 0015cde8       12 Free 00a71024 5ba58328       68 00a71068 5ba58380       68 00a710ac 5ba58430       68 00a710f0 5ba5dba4       68 ... total 619 objects Statistics:       MT    Count TotalSize Class Name 5ba7607c        1        12 System.Security.Permissions.HostProtectionResource 5ba75d54        1        12 System.Security.Permissions.SecurityPermissionFlag 5ba61f18        1        12 System.Collections.CaseInsensitiveComparer ... 0015cde8        6     10260      Free 5ba57bf8      318     18136 System.String ...
"Free" objects are simply regions of space the garbage collector can use later.If 30% or more of the heap contains "Free" objects, the process may suffer fromheap fragmentation. This is usually caused by pinning objects for a long time combined with a high rate of allocation. Here is example output where !DumpHeapprovides a warning about fragmentation:
 &lt;After the Statistics section&gt; Fragmented blocks larger than 1MB:     Addr     Size Followed by 00a780c0    1.5MB    00bec800 System.Byte[] 00da4e38    1.2MB    00ed2c00 System.Byte[] 00f16df0    1.2MB    01044338 System.Byte[]
The arguments in detail:
-stat     Restrict the output to the statistical type summary-strings  Restrict the output to a statistical string value summary-short    Limits output to just the address of each object. This allows you          to easily pipe output from the command to another debugger           command for automation.-min      Ignore objects less than the size given in bytes-max      Ignore objects larger than the size given in bytes-live     Only print live objects-dead     Only print dead objects (objects which will be collected in the          next full GC)-thinlock Report on any ThinLocks (an efficient locking scheme, see !SyncBlk           documentation for more info)-startAtLowerBound           Force heap walk to begin at lower bound of a supplied address range.          (During plan phase, the heap is often not walkable because objects           are being moved. In this case, DumpHeap may report spurious errors,           in particular bad objects. It may be possible to traverse more of           the heap after the reported bad object. Even if you specify an           address range, !DumpHeap will start its walk from the beginning of           the heap by default. If it finds a bad object before the specified           range, it will stop before displaying the part of the heap in which           you are interested. This switch will force !DumpHeap to begin its           walk at the specified lower bound. You must supply the address of a           good object as the lower bound for this to work. Display memory at           the address of the bad object to manually find the next method           table (use !dumpmt to verify). If the GC is currently in a call to           memcopy, You may also be able to find the next object's address by           adding the size to the start address given as parameters.) -mt       List only those objects with the MethodTable given-type     List only those objects whose type name is a substring match of the           string provided. start     Begin listing from this addressend       Stop listing at this address
A special note about -type: Often, you'd like to find not only Strings, butSystem.Object arrays that are constrained to contain Strings. ("new String[100]" actually creates a System.Object array, but it can only holdSystem.String object pointers). You can use -type in a special way to findthese arrays. Just pass "-type System.String[]" and those Object arrays willbe returned. More generally, "-type &lt;Substring of interesting type&gt;[]".
The start/end parameters can be obtained from the output of !EEHeap -gc. For example, if you only want to list objects in the large heap segment:
 0:000&gt; !eeheap -gc Number of GC Heaps: 1 generation 0 starts at 0x00c32754 generation 1 starts at 0x00c32748 generation 2 starts at 0x00a71000 segment    begin allocated     size 00a70000 00a71000  010443a8 005d33a8(6108072) Large object heap starts at 0x01a71000 segment    begin allocated     size 01a70000 01a71000  01a75000 0x00004000(16384) Total Size  0x5d73a8(6124456) ------------------------------ GC Heap Size  0x5d73a8(6124456)
 0:000&gt; !dumpheap 1a71000 1a75000 Address       MT     Size 01a71000 5ba88bd8     2064 01a71810 0019fe48     2032 Free 01a72000 5ba88bd8     4096 01a73000 0019fe48     4096 Free 01a74000 5ba88bd8     4096 total 5 objects Statistics:       MT    Count TotalSize Class Name 0019fe48        2      6128      Free 5ba88bd8        3     10256 System.Object[] Total 5 objects
Finally, if GC heap corruption is present, you may see an error like this:
 0:000&gt; !dumpheap -stat object 00a73d24: does not have valid MT curr_object : 00a73d24 Last good object: 00a73d14 ----------------
That indicates a serious problem. See the help for !VerifyHeap for more information on diagnosing the cause.</pre>
&nbsp;
<blockquote>We can use DumpHeap command to look for memory leak issues in our application.</blockquote>
<pre></pre>

&nbsp;

following are the different usecase of dumpheap command

<ul>
 	<li>To get all the strings loaded into our application</li>
</ul>
<pre>0:002&gt; !dumpheap -strings
 00000000023313f0 000007fec5c87be8 26
 00000000023314c0 000007fec5c87be8 42
 0000000002331600 000007fec5c87be8 94
 0000000002331680 000007fec5c87be8 46
 00000000023316b0 000007fec5c87be8 74
 0000000002331700 000007fec5c87be8 40
 00000000023317e8 000007fec5c87be8 80
 0000000002331838 000007fec5c87be8 27448
 0000000002338370 000007fec5c87be8 84
 00000000023383c8 000007fec5c87be8 146
 0000000002338460 000007fec5c87be8 72
 00000000023384a8 000007fec5c87be8 68
 00000000023384f0 000007fec5c87be8 98
 0000000002338558 000007fec5c87be8 78
 00000000023385a8 000007fec5c87be8 112
 0000000002338618 000007fec5c87be8 70

===============trimmed=====================

42 1 HH:mm:ss
 42 1 November
 42 1 Saturday
 42 1 Thursday
 42 1 encoding
 42 1 hh:mm tt
 42 1 December
 42 1 February
 42 1 Infinity
 42 1 Internet
 42 1 JIT_PATH
 44 1 September
 44 1 FullTrust
 44 1 yyyy MMMM
 44 1 -Infinity
 44 1 APP_PATHS
 44 1 Wednesday
 46 1 MM/dd/yyyy
 46 1 yyyy-MM-dd
 48 1 MultiDomain
 50 1 NotSpecified
 50 1 FX_DEPS_FILE
 50 1 APP_NI_PATHS
 50 1 SingleDomain
 50 1 Hello World!
 56 1 MultiDomainHost
 60 1 Invariant Country
 62 1 Gregorian Calendar
 62 1 Invariant Language
 62 1 dddd, dd MMMM yyyy
 64 1 PROBING_DIRECTORIES
 64 1 LOADER_OPTIMIZATION
 66 1 ArrayPoolEventSource
 68 1 !x-sys-default-locale
 68 2 Name
 68 1 APP_LOCAL_WINMETADATA
 68 1 RFLCT_InvalidPropFail
 70 1 RFLCT_InvalidFieldFail
 70 1 APP_CONTEXT_DEPS_FILES
 72 2 en-us
 72 2 bytes
 72 2 chars
 78 1 APP_CONTEXT_BASE_DIRECTORY
 80 1 International Monetary Fund
 86 1 System.Globalization.Invariant
 88 2 charCount
 88 2 byteCount
 88 2 charIndex
 90 1 UseRandomizedStringHashAlgorithm
 92 2 dotnet.exe
 96 1 SYSTEM.BUFFERS.ARRAYPOOLEVENTSOURCE
 98 1 UseLatestBehaviorWhenTFMNotSpecified
 102 1 Invariant Language (Invariant Country)
 108 3 en-US
 112 1 D:\PROJECTS\dotnet\bin\Debug\netcoreapp2.0\
 122 1 System.Diagnostics.Eventing.FrameworkEventSource
 130 1 ERROR: Exception during construction of EventSource
 136 2 AppDomainCompatSwitch
 144 2 PLATFORM_RESOURCE_ROOTS
 146 1 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\;
 148 2 C:\Program Files\dotnet\
 160 2 TRUSTED_PLATFORM_ASSEMBLIES
 164 1 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\clrj
 168 1 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\msco
 168 2 NATIVE_DLL_SEARCH_DIRECTORIES
 174 1 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\Wind
 174 1 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\SOS.
 174 1 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\nets
 188 2 C:\Program Files\dotnet\dotnet.exe
 192 2 System.Buffers.ArrayPoolEventSource
 264 2 D:\PROJECTS\dotnet\bin\Debug\netcoreapp2.0\dotnet.dll
 298 1 C:\Program Files\dotnet\store\x64\netcoreapp2.0;C:\Users\rkolak
 326 1 D:\PROJECTS\dotnet\bin\Debug\netcoreapp2.0\dotnet.deps.json;C:\
 988 5 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\Micr
 29538 146 C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\Syst
 54894 2 D:\PROJECTS\dotnet\bin\Debug\netcoreapp2.0\dotnet.dll;C:\Progra</pre>
<blockquote>You can get all the strings from the process e.g. your password stored as plaintext and stored in config if you are loading that into memory,you will be able to see it here.</blockquote>
<ul>
 	<li><strong>To check the objects in LOH Large Object Heap</strong></li>
</ul>
any objects which are more than 85000 bytes will be stored in Large Object Heap(LOH) and lot of objects in LOH can cause memory issues in your application.

<strong>0:002&gt; !dumpheap -min 85000</strong>
Address MT Size

Statistics:
MT Count TotalSize Class Name
Total 0 objects

We did not get any large objects
<ul>
 	<li><strong>How many objects are locked using lock statements</strong></li>
</ul>
<pre>0:002&gt; !dumpheap -thinlock
 Address MT Size
 0000000002355260 000007fe7157cdb8 24 ThinLock owner 1 (00000000005cb900) Recursive 0
 Found 1 objects.</pre>
<pre><strong>0:002&gt; !do 0000000002355260</strong>
 Name: System.IO.SyncTextReader
 MethodTable: 000007fe7157cdb8
 EEClass: 000007fe716cbc98
 Size: 24(0x18) bytes
 File: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\System.Console.dll
 Fields:
 MT Field Offset Type VT Attr Value Name
 000007fe7157c520 40001a5 d0 System.IO.TextReader 0 static 0000000000000000 Null
 000007fe7157c520 400011c 8 System.IO.TextReader 0 instance 00000000023548a0 _in
 ThinLock owner 1 (00000000005cb900), Recursive 0</pre>
<ul>
 	<li>Dump all the objects of a particular type</li>
</ul>
<pre><strong>0:002&gt; !dumpheap -type Console</strong>
 Address MT Size
 00000000023530e0 000007fe715790d8 24
 0000000002353178 000007fe71579e10 56
 0000000002353330 000007fe7157b4b8 56
 0000000002354700 000007fe71579e10 56
 0000000002354810 000007fe7157b4b8 56

Statistics:
 MT Count TotalSize Class Name
 000007fe715790d8 1 24 System.Console+&lt;&gt;c
 000007fe7157b4b8 2 112 System.Text.ConsoleEncoding
 000007fe71579e10 2 112 System.ConsolePal+WindowsConsoleStream
 Total 5 objects</pre>
<h3>Dumping an object from process and looking at all properties</h3>
To get the details of any object,we will be using !DumpObject command.To this command,you have to pass the Object Address.Normally we use DumpObject command along with another command(dumpheap). We will first use dumpheap to find the address of a particular tpe of object and then use DumpObject(!do is alias) to further drill down
<pre><strong>0:002&gt; !dumpheap -type Console</strong>
 Address MT Size
 00000000023530e0 000007fe715790d8 24
 0000000002353178 000007fe71579e10 56
 0000000002353330 000007fe7157b4b8 56
 0000000002354700 000007fe71579e10 56
 0000000002354810 000007fe7157b4b8 56

Statistics:
 MT Count TotalSize Class Name
 000007fe715790d8 1 24 System.Console+&lt;&gt;c
 000007fe7157b4b8 2 112 System.Text.ConsoleEncoding
 000007fe71579e10 2 112 System.ConsolePal+WindowsConsoleStream
 Total 5 objects
 <strong>0:002&gt; !do 00000000023530e0</strong>
 Name: System.Console+&lt;&gt;c
 MethodTable: 000007fe715790d8
 EEClass: 000007fe716cadc0
 Size: 24(0x18) bytes
 File: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5\System.Console.dll
 Fields:
 MT Field Offset Type VT Attr Value Name
 000007fe715790d8 4000044 60 System.Console+&lt;&gt;c 0 static 00000000023530e0 &lt;&gt;9
 000007fe7157c6e0 4000045 68 ...time.Extensions]] 0 static 00000000023546c0 &lt;&gt;9__13_0
 000007fe71567c28 4000046 70 ...Private.CoreLib]] 0 static 0000000002354738 &lt;&gt;9__15_0
 000007fe71567c28 4000047 78 ...Private.CoreLib]] 0 static 00000000023531b0 &lt;&gt;9__18_0
 000007fe71579188 4000048 80 ...time.Extensions]] 0 static 00000000023530f8 &lt;&gt;9__25_0
 000007fe71579188 4000049 88 ...time.Extensions]] 0 static 0000000000000000 &lt;&gt;9__27_0
 0000000000000000 400004a 90 0 static 0000000000000000 &lt;&gt;9__33_0
 0000000000000000 400004b 98 0 static 0000000000000000 &lt;&gt;9__35_0
 0000000000000000 400004c a0 0 static 0000000000000000 &lt;&gt;9__37_0
 000007fec5c701d8 400004d a8 ...Private.CoreLib]] 0 static 0000000000000000 &lt;&gt;9__151_0</pre>
&nbsp;

In our next post we will explore looking inside a ASP.NET CORE process.We will also explore more detail  commands which can help you find memory leak inside a asp.net core process.]]></content:encoded>
    </item>
    <item>
      <title>Starting a fresh Progressive Web App project from scratch with ReactJs,Redux ,Typescript ,TDD and VSCode Debugging</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/starting-a-fresh-progressive-web-app-project-from-scratch-with-reactjsredux-typescript-tdd-with-vscode-debugging</link>
      <pubDate>Wed, 21 Mar 2018 08:47:58 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=225</guid>
      <description><![CDATA[If you are going to start a new React Project from scratch,You may  want to have many feature sets...]]></description>
      <content:encoded><![CDATA[If you are going to start a new React Project from scratch,You may  want to have many feature sets to start with  e.g. <span><a href="https://developers.google.com/web/progressive-web-apps/">Progressive Web Apps support</a> , <a href="https://www.typescriptlang.org/docs/handbook/react-&amp;-webpack.html">Typescript with a build system</a>, </span>how to do TDD ,How to debug,How to architect the codebase and the list goes on.So this basic skeleton will make sure everything is in order from start.

Easiest thing to do is start with a boiler plate project which will give you with lot of options out of the box.Some good ones are
<ul>
 	<li><a href="https://github.com/facebook/create-react-app">create-react-app</a></li>
 	<li><a href="https://github.com/react-boilerplate/react-boilerplate">React-Boilerplate</a></li>
 	<li><a href="https://github.com/iroy2000/react-redux-boilerplate">react-redux-boilerplate</a></li>
 	<li>and there are lot of <a href="https://reactjs.org/community/starter-kits.html">starter kits</a> to choose from</li>
</ul>
For example,following are some of the feature-sets I want in my new project
<ul>
 	<li><span><a href="https://developers.google.com/web/progressive-web-apps/">Progressive Web Apps support</a> </span></li>
 	<li>TypeScript(Or Flow) support</li>
 	<li>Setting up a Mock API Server</li>
 	<li>BDD/TDD</li>
 	<li>Debugging support in your IDE (<a href="https://code.visualstudio.com/">VS Code</a>)</li>
 	<li>Routing Support</li>
 	<li>use Redux(Or Mobx)</li>
</ul>
In this we are going to start a new project from scratch with <a href="https://github.com/facebook/create-react-app">Create-React-App</a> and then add features one by one.<a href="https://github.com/facebook/create-react-app"> Create-React-App</a> is ideal just hides/expose enough details at the same time let's you add these features one by one and once you want more advanced features,you can <a href="https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md">eject </a>and get a full power . For completed app, Please find the source code <a href="https://github.com/rohithkrajan/react-redux-ts">here</a>
<h3>Starting up</h3>
Creating a new project with Create-react-app is explained  <a href="https://github.com/facebook/create-react-app#creating-an-app">here</a>   but the gist of it are couple of commands
<pre>npm install -g create-react-app

<code>create-react-app my-app</code></pre>
<strong>This will create your project called my-app but do not create your project just yet, we will do that in our next section .</strong>

Under the hood create-react-app <span>sets up a fully functional, offline-first </span><a href="https://developers.google.com/web/progressive-web-apps/">Progressive Web App</a><span> .</span>
<blockquote><span>Progressive Web Apps (PWAs) are web applications that use advanced modern web technologies that behave like native app e.g. load instantly, regardless of the network state or respond quickly to user interactions </span></blockquote>
<h3>PWA with TypeScript support</h3>
<span>JavaScript's lack of static types is a major concern especially if you are used to  Java/.NET. Static type checking helps you iron out a lot of bugs at compile time and also make your app from running into any Undefined errors :)  .In this case we are going to use TypeScript </span>

and alsol get following features out of the box
<ul>
 	<li>PWA capabilities</li>
 	<li>a project with React and TypeScript</li>
 	<li>linting with<span> </span><a href="https://github.com/palantir/tslint">TSLint</a></li>
 	<li>testing with<span> </span><a href="https://facebook.github.io/jest/" rel="nofollow">Jest</a><span> </span>and<span> </span><a href="http://airbnb.io/enzyme/" rel="nofollow">Enzyme</a>, and</li>
 	<li>state management with<span> </span><a href="https://github.com/reactjs/react-redux">Redux</a></li>
</ul>
We will use <strong class="markup--strong markup--blockquote-strong"><em class="markup--em markup--blockquote-em">create-react-app</em></strong><span> </span> but we will have to pass the <strong>react-scripts-ts</strong> as scripts-version argument. What this will do is add <strong>react-scripts-ts </strong>as development dependency and your underlying build system can now understand typescript whenever you test/run your project:
<pre>create-react-app my-pwa-app --scripts-version=react-scripts-ts</pre>
So if you look closely ,you will see following lines in your packages.json file
<pre> "scripts": {
 "start": "<strong>react-scripts-ts</strong> start",
 "build": "<strong>react-scripts-ts</strong> build",
 "test": "<strong>react-scripts-ts</strong> test --env=jsdom",
 "eject": "<strong>react-scripts-ts</strong> eject"
 }

</pre>
Just to compare,without react-scripts-ts ,it will be
<pre>scripts": {
 "start": "<strong>react-scripts</strong> start",
 "build": "react-scripts build",
 "test": "react-scripts test --env=jsdom",
 "eject": "react-scripts eject"
 }</pre>
So every time you run commands like npm start or npm build you are basically calling it though the <strong>react-scripts-ts. </strong>
<blockquote><strong> react-scripts-ts is the magic which will make sure your project is using TypeScript at development time which is installed as development dependency</strong></blockquote>
<pre>Once you have your application created, you will have following structure

<strong></strong>

my-pwa-app
├── README.md
├── node_modules
├── package.json
├── .gitignore
├── public
│ └── favicon.ico
│ └── index.html
│ └── manifest.json
└── src
│ └── App.css
│ └── App.tsx
│ └── App.test.tsx
│ └── index.css
│ └── index.tsx
│ └── logo.svg
│ └── registerServiceWorker.ts
├── tsconfig.json
├── tsconfig.test.json
├── tslint.json</pre>
<blockquote>In this <span style="float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 24px;text-align: left;text-decoration: none;text-indent: 0px">registerServiceWorker.ts</span> is the script which will make use of <a href="https://developers.google.com/web/fundamentals/primers/service-workers/">service workers</a><span style="float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 24px;text-align: left;text-decoration: none;text-indent: 0px"> </span> to make our application Progressive Web App.</blockquote>
<div>
<div>This script registers <span>a service worker to serve assets from local cache in production.</span><span> This lets the app load faster on subsequent visits in production, and gives</span><span> it offline capabilities. </span><span>To learn more about the pros and cons, read <a href="https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app">this</a>.</span><span> This link also includes instructions on opting out of this behavior.</span></div>
</div>
<h3>Setting up Mock API server for your backend</h3>
Normally you will be having a back-end in another project (e.g. asp.net web api )  ,Java (e.g. spring boot )  When you develop/debug/run a front end application,you have two options
<ol>
 	<li>Run a backend everytime you run your frontend for debugging</li>
 	<li>Setup a fake api which will behave like your backend but without running any of the dependent services</li>
</ol>
We will be using <strong><a href="https://github.com/typicode/json-server">json-server</a></strong> to set up the fake API backend

You can install it as globally or locally as i use it for multiple projects,I install as globally
<pre>npm install -g json-server</pre>
json-server works with a json file which we will call <strong>db.json</strong>
<pre>{
  <span class="pl-s"><span class="pl-pds">"</span>blogs<span class="pl-pds">"</span></span>: [
    { <span class="pl-s"><span class="pl-pds">"</span>id<span class="pl-pds">"</span></span>: <span class="pl-c1">1</span>, <span class="pl-s"><span class="pl-pds">"</span>title<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>json-server<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>author<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>rohith<span class="pl-pds">"</span></span> }
  ],
  <span class="pl-s"><span class="pl-pds">"</span>comments<span class="pl-pds">"</span></span>: [
    { <span class="pl-s"><span class="pl-pds">"</span>id<span class="pl-pds">"</span></span>: <span class="pl-c1">1</span>, <span class="pl-s"><span class="pl-pds">"</span>body<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>some comment<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>postId<span class="pl-pds">"</span></span>: <span class="pl-c1">1</span> }
  ]
}</pre>
Once you have your db.json file,you can run command
<pre><strong>json-server --watch db.json</strong></pre>
Now if you go to<span> </span><a href="http://localhost:3000/posts/1" rel="nofollow">http://localhost:3000/blogs/1</a>, you'll get
<div class="highlight highlight-source-json">
<pre>{ <span class="pl-s"><span class="pl-pds">"</span>id<span class="pl-pds">"</span></span>: <span class="pl-c1">1</span>, <span class="pl-s"><span class="pl-pds">"</span>title<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>json-server<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>author<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>rohith<span class="pl-pds">"</span></span> }</pre>
Now we have to add json-server to our react project but what I need is a visual studio like experience, when I press F5 or start debugging,it should automatically start both front end and fake api backend

We will use two npm packages <span><strong>concurrently </strong>and cross-env and </span>to make the job easy . <span><strong>concurrently</strong> can run multiple concurrent scripts (or commands ) at the same time. <strong>cross-env</strong> will make sure the command runs fine on all enviroments(whether you develop on windows or Linux or MacOS) .So to summarise,we need 3 npm packages and following configuration in our packages.json file</span>
<div>
<pre><span>"scripts"</span><span>: {</span>
<span>    </span><span>"start"</span><span>: </span><span>"concurrently --kill-others </span><span>\"</span><span>cross-env NODE_PATH=src react-scripts-ts start</span><span>\"</span><span> </span><span>\"</span><span>npm run server</span><span>\"</span><span>"</span><span>,</span>
<span>    </span><span>"build"</span><span>: </span><span>"cross-env NODE_PATH=src react-scripts-ts build"</span><span>,</span>
<span>    </span><span>"test"</span><span>: </span><span>"cross-env NODE_PATH=src react-scripts-ts test --env=jsdom"</span><span>,</span>
<span>    </span><span>"eject"</span><span>: </span><span>"cross-env NODE_PATH=src react-scripts-ts eject"</span><span>,</span>
<span>    </span><span>"server"</span><span>: </span><span>"json-server --watch --port 3001 ./src/api/db.json"</span>
<span>  }</span></pre>
</div>
So I added another another script called server where i specified the port as 3001 and also put the db.json file n the api folder
<pre><span class="pl-s"><span class="pl-pds">"</span>server<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>json-server --watch --port 3001 ./src/api/db.json<span class="pl-pds">"</span></span></pre>
and start has been modified to run two commands concurrently using <strong>concurrently </strong>
<pre>"start": "concurrently --kill-others \"cross-env NODE_PATH=src react-scripts-ts start\" \"npm run server\""</pre>
</div>
Now every time we do npm start, it will start our fake api and also start the react app
<h3>VSCode Debugging support</h3>
We will try to setup Visual Studio Code to debug our ReactJS project with following feaures
<ul>
 	<li>Setting breakpoints, including in source files when source maps are enabled</li>
 	<li>Stepping, including with the buttons on the Chrome page</li>
 	<li>The Locals pane</li>
 	<li>Debugging eval scripts, script tags, and scripts that are added dynamically</li>
 	<li>Watches</li>
 	<li>Console</li>
</ul>
First You need to install a Visual Studio Code Extension <a href="https://github.com/Microsoft/vscode-chrome-debug">VS Code -Debugger for chrome </a> then add the following launch.json to your project .vscode/launch.json
<pre>{
 "version": "0.2.0",
 "configurations": [{
 "name": "Chrome",
 "type": "chrome",
 "request": "launch",
 "url": "http://localhost:3000",
 "webRoot": "${workspaceRoot}/src",
 "sourceMapPathOverrides": {
 "webpack:///src/*": "${webRoot}/*"
 }
 }]
 }</pre>
Once you have the launch.json, now
<ul>
 	<li><span>Start your app by running </span><code>npm start</code></li>
 	<li><span>start debugging in VS Code by pressing </span><code>F5</code><span> or by clicking the green debug icon</span></li>
</ul>
put a breakpoint in any tsx or ts file and debug to oblivion :)
<h3>How to BDD/TDD/E2E Testing</h3>
<span style="float: none;background-color: transparent;color: #24292e;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;text-align: left;text-decoration: none;text-indent: 0px">Create React App uses </span><a href="https://facebook.github.io/jest/" rel="nofollow">Jest</a><span style="float: none;background-color: transparent;color: #24292e;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;text-align: left;text-decoration: none;text-indent: 0px"> as its test runner</span> . To learn more  follow the <a href="https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests">running tests</a>

In our App, We will try to do 3 types of tests
<ul>
 	<li>Unit Testing</li>
 	<li>Component testing</li>
 	<li>End to End Testing(E2E)</li>
</ul>
<h4>Unit testing</h4>
Unit Testing is used <span style="float: none;background-color: transparent;color: #24292e;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;text-align: left;text-decoration: none;text-indent: 0px">testing the smallest possible </span><em>units</em><span style="float: none;background-color: transparent;color: #24292e;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;text-align: left;text-decoration: none;text-indent: 0px"> of our code, functions.  Let's work with a Hello World in a Typescript and Jest </span>

<span>We will create a directory called common inside src and add all common domain objects here</span>

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/helloworld_tdd_typescript_jest.png"><img width="223" height="300" class="alignnone wp-image-345 size-medium" alt="helloworld in typescript with Jest unit testing" src="https://msdnshared.blob.core.windows.net/media/2018/03/helloworld_tdd_typescript_jest-223x300.png" /></a>

add a main.ts inside the common directory
<div>
<div>

[js]
class Greeter {
    greeting: string;
    constructor(message: string) {
        this.greeting = message;
    }
    greet() {
        return &quot;Hello, &quot; + this.greeting;
    }
}

class Calculator {        
    add(a:number,b:number) {
        return a+b;
    }
    
    sub(a:number,b:number) {
        return a-b;
    }
}
export {Greeter,Calculator}
[/js]

<span> </span>

</div>
</div>
<span style="float: none;background-color: transparent;color: #24292e;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;text-align: left;text-decoration: none;text-indent: 0px">And a <strong>main.test.ts</strong> </span>

[js]&amp;amp;amp;amp;amp;amp;lt;br data-mce-bogus=&quot;1&quot;&amp;amp;amp;amp;amp;amp;gt;

import { Greeter, Calculator } from './main';

it('greets the world', () =&amp;amp;amp;amp;amp;amp;amp;gt; {
 let greeter = new Greeter(&quot;World&quot;);
 expect(greeter.greet()).toEqual(&quot;Hello, World&quot;);
});
it('add/substract two numbers', () =&amp;amp;amp;amp;amp;amp;amp;gt; {
 let calc = new Calculator();
 expect(calc.add(2, 3)).toEqual(5);
 expect(calc.sub(3, 2)).toEqual(1);
});

[/js]

&nbsp;

When we run the test using <strong>npm test</strong>, it will give
<div>
<pre></pre>
</div>
<pre>E:\Projects\my-pwa-app&gt;npm test

&gt; my-pwa-app@0.1.0 test E:\Projects\my-pwa-app
&gt; react-scripts-ts test --env=jsdom

PASS src\common\main.test.ts
 √ greets the world (4ms)
 √ add/substract two numbers (1ms)

Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 2.234s
Ran all test suites related to changed files.</pre>
<h4>Component Testing</h4>
Component testing let's you test your components using one level deep (Shallow Rendering ) or test components and all it's children

I have a component called <strong>Header</strong> which is using <strong>Link  </strong>component from react-router .But using ShallowRendering we can test just  <strong>Header</strong> component

[js]

import * as React from &quot;react&quot;;
import { Link } from 'react-router';

export interface HeaderProps {
type: string,
id?: string
}

export default class Header extends React.Component&lt;HeaderProps, object&gt; {

public renderLinks(): JSX.Element {
const { type } = this.props;
if (type === &quot;merchants_index&quot;) {
return (
&lt;ul className=&quot;nav nav-pills navbar-right&quot;&gt;
&lt;li style={{ paddingRight: '10px' }} role=&quot;presentation&quot;&gt;
&lt;Link className=&quot;text-xs-right&quot; style={{ color: '#337ab7', fontSize: '17px' }}
to=&quot;/merchant/new&quot;&gt;New Merchant&lt;/Link&gt;
&lt;/li&gt;
&lt;/ul&gt;
);
}
else
return (
&lt;div&gt;&lt;/div&gt;
);
}
public render() {
return (
&lt;div&gt;

&lt;nav className=&quot;navbar navbar-default navbar-static-top&quot;&gt;
&lt;div id=&quot;navbar&quot; className=&quot;navbar-collapse collapse&quot;&gt;
&lt;div className=&quot;container&quot;&gt;
&lt;ul className=&quot;nav nav-pills navbar-left&quot;&gt;
&lt;li style={{ paddingRight: '10px' }} role=&quot;presentation&quot;&gt;
&lt;Link className=&quot;text-xs-right&quot;
style={{ color: '#337ab7', fontSize: '17px' }} to=&quot;/&quot;&gt;Home&lt;/Link&gt;
&lt;/li&gt;
&lt;/ul&gt;
{this.renderLinks()}
&lt;/div&gt;
&lt;/div&gt;
&lt;/nav&gt;
&lt;/div&gt;
);
}

}

[/js]

<pre></pre>
<div>
<div>Now lets add required packages ,we will be using Enzyme and the shallow <a href="http://airbnb.io/enzyme/docs/api/shallow.html">API </a> to test</div>
</div>
<div></div>
<pre><span style="float: none;background-color: #f6f8fa;color: #24292e;font-family: 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size: 13.6px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 19.72px;text-align: left;text-decoration: none;text-indent: 0px">npm install --save enzyme enzyme-adapter-react-16 react-test-renderer</span></pre>
<div></div>
<div></div>
<div>

[js]&lt;/div&gt;
&lt;pre&gt;import * as React from 'react';
import * as enzyme from 'enzyme';
import Header from './Header';
import * as Adapter from 'enzyme-adapter-react-16';

enzyme.configure({ adapter: new Adapter() });

it(&quot;renders 'new merchant' link in the header when type is merchants_index&quot;,()=&gt;{
 const header=enzyme.render(&lt;Header type=&quot;merchants_index&quot;/&gt;);
 expect(header.find(&quot;.text-xs-right&quot;).text()).toContain(&quot;New Merchant&quot;)
});
[/js]

<h4>End to End (E2E) testing</h4>
for E2E testing,we will be using <a href="https://github.com/DevExpress/testcafe">testcafe </a>and also the typescript support is <a href="http://devexpress.github.io/testcafe/documentation/test-api/typescript-support.html">good</a>. You basically have to install <span>testcafe</span> and <span>testcafe-react-selectors .</span>

You can find more details on this <a href="https://hackernoon.com/e2e-testing-react-applications-with-testcafe-8edb605ec66c">here </a> or <a href="https://medium.com/@mwq27/better-e2e-testing-with-testcafe-666aacf2a94e">here</a>

&nbsp;
<h3>Support for Routing</h3>
There are many routing solution but <a href="https://reacttraining.com/react-router/">ReactRouter </a>is the most popular one,to add it to our project

npm install --save react-router-dom

First we have to add the require wiring up in index.tsx , you can see this in <a href="https://github.com/rohithkrajan/react-redux-ts/blob/master/src/index.tsx">index.tsx </a>inside the repository

[js]
&lt;pre&gt;import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
&lt;strong&gt;import routes from './routes';&lt;/strong&gt;
import registerServiceWorker from './registerServiceWorker';
import './index.css';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';

import { createStore } from 'redux';
import { merchantsReducer } from './reducers/index';
import { StoreState } from './types/index';

const store = createStore&lt;StoreState&gt;(merchantsReducer);

ReactDOM.render( 
 &lt;Provider store={store}&gt; 
 &lt;strong&gt;&lt;Router history={browserHistory} routes={routes} /&gt;&lt;/strong&gt;
 &lt;/Provider&gt;,
 document.getElementById('root') as HTMLElement
);
registerServiceWorker();&lt;/pre&gt;
[/js]

And we will create a our Routes in Routes.tsx file

[js]
import * as React from 'react';
import { Route,IndexRoute } from 'react-router';

import App from './App';
import MerchantIndex from './components/MerchantsIndex';
import HomePage from './components/Jumbotron';
import MerchantDetailsContainer from './containers/MerchantDetailsContainer'

export default (
 &lt;Route path=&quot;/&quot; component={App}&gt;
 &lt;IndexRoute component={MerchantIndex}/&gt;
 &lt;Route path=&quot;merchants/new&quot; component={HomePage}/&gt;
 &lt;Route path=&quot;merchants/:id&quot; component={MerchantDetailsContainer}/&gt;
 &lt;/Route&gt;
)
[/js]

<h3>Using  Redux (Or Mobx)</h3>
Here also you can choose to use Redux or MobX and both has it's <a href="https://www.robinwieruch.de/redux-mobx-confusion/">pros and cons</a>  or checkout this <a href="https://codeburst.io/mobx-vs-redux-with-react-a-noobs-comparison-and-questions-382ba340be09">comparison </a>.But in this case we are going to use Redux .But with redux comes a bunch of other requirements :
<ul>
 	<li>Defining our app's state</li>
 	<li>Adding actions</li>
 	<li>Adding a reducer</li>
 	<li>How to use Presentation and container Components</li>
</ul>
We have State in TypeScript

[js]
&lt;pre&gt;import {Merchant} from '../common/Merchant';

export interface MerchantsList
{
 merchants:Merchant[];
 error:any;
 loading:boolean;
}
export interface MerchantData
{
 merchant:Merchant|null;
 error:any;
 loading:boolean;
}
export interface StoreState
{
 merchantsList:MerchantsList;
 newMerchant:MerchantData;
 activeMerchant:MerchantData;
 deletedMerchant:MerchantData;
}&lt;/pre&gt;
Now we will have a directory named actions created  and inside that I will have
&lt;pre&gt;import axios, { AxiosPromise } from 'axios';
import * as constants from '../constants'
import { Merchant } from '../common/Merchant';
import { ROOT_URL } from './index';
//import { RESET_ACTIVE_MERCHANT } from '../constants';



export interface FetchMerchant {
 type: constants.FETCH_MERCHANT,
 payload: AxiosPromise&lt;any&gt;
}

export interface FetchMerchantSuccess {
 type: constants.FETCH_MERCHANT_SUCCESS,
 payload: Merchant
}



export interface FetchMerchantFailure {
 type: constants.FETCH_MERCHANT_FAILURE,
 payload: any
}

export interface ResetActiveMerchant {
 type: constants.RESET_ACTIVE_MERCHANT
}

export type MerchantDetailAction = FetchMerchant | FetchMerchantSuccess | FetchMerchantFailure | ResetActiveMerchant;

export function fetchMerchant(id:string): FetchMerchant {
 const request = axios({
 method: 'get',
 url: `${ROOT_URL}/merchants/${id}`,
 headers: []
 });
 return {
 type: constants.FETCH_MERCHANT,
 payload: request
 };
}

export function fetchMerchantSuccess(merchant: Merchant): FetchMerchantSuccess {
 return {
 type: constants.FETCH_MERCHANT_SUCCESS,
 payload: merchant
 };
}

export function fetchMerchantFailure(error: any): FetchMerchantFailure {
 return {
 type: constants.FETCH_MERCHANT_FAILURE,
 payload: error
 };
}



export function resetActiveMerchants(): ResetActiveMerchant {
 return {
 type: constants.RESET_ACTIVE_MERCHANT
 };
}
[/js]

I also have Presentational and Container components created and you can see all this action in github project <a href="https://github.com/rohithkrajan/react-redux-ts">https://github.com/rohithkrajan/react-redux-ts</a>

&nbsp;

Hope this helps!

</div>]]></content:encoded>
    </item>
    <item>
      <title>ASP.NET MVC 5 with BDD ,Onion/Clean Architecture, Living documentation and a CI/CD pipeline from scratch</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/asp-net-mvc-5-with-bdd-clean-or-onion-architecture-living-documentation-and-a-cicd-pipeline-from-scratch</link>
      <pubDate>Thu, 15 Mar 2018 07:43:55 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=275</guid>
      <description><![CDATA[To give you a little background, I was toying with an idea for a startup and wrote a quick...]]></description>
      <content:encoded><![CDATA[To give you a little background, I was toying with an idea for a startup and wrote a quick application in ASP.NET as a POC for exploring a product idea (<a href="https://www.investopedia.com/terms/r/reconciliation.asp">Reconcilation </a>) .Although I left the idea for the product   and the startup ,there are many things I thought would be good idea  to share with you.
<ul>
 	<li>Demo App - <a href="http://finreconcile.azurewebsites.net">http://finreconcile.azurewebsites.net</a></li>
 	<li>Slide Deck for easy summary -<a href="http://finreconcile.azurewebsites.net/finreconcile.html">http://finreconcile.azurewebsites.net/finreconcile.html</a></li>
 	<li><a href="https://github.com/rohithkrajan/FinReconcile">Source code</a></li>
</ul>
Following are the ideas explored in this blog post
<ul>
 	<li>Write a RuleEngine in C# which is extensible and configurable</li>
 	<li>Follow a Behavior-driven development (BDD) approach to develop .In this case the full asp.net MVC app ,RuleEngine etc are developed using BDD.</li>
 	<li>Generate Living documentation from BDD specs .</li>
 	<li>Implement a CI/CD pipeline and deploy to Azure App Service
<ul>
 	<li>Visual Studio Team Services is configured to have CI/CD pipeline and automatic deployment  to Azure</li>
 	<li>As an alternate approach,implement similar CI/CD pipeline in another platform like <a href="https://ci.appveyor.com/project/rohithkrajan/finreconcile">AppVeyor</a></li>
</ul>
</li>
 	<li>Get a basic understanding of Clean/Onion architecture</li>
</ul>
<a href="http://finreconcile.azurewebsites.net/"></a>
<h3>Writing a simple RuleEngine in C#</h3>
Writing a Rule Engine in C# is made easy with System.Linq.Expressions , since we followed BDD approach you can find a live documentaion generated from the test spec in the below link

<a href="http://finreconcile.azurewebsites.net/docs/Index.html?feature=Rules.feature">http://finreconcile.azurewebsites.net/docs/Index.html?feature=Rules.feature</a>

I have also created documentation in the wiki for the  RuleEngine.

<a href="https://github.com/rohithkrajan/FinReconcile/wiki/Rule-Engine">https://github.com/rohithkrajan/FinReconcile/wiki/Rule-Engine</a>

I will be writing another blog post covering how the ruleengine works  and what are the design choices but it is outside the scope of this post.
<h3>BDD approach</h3>
Before getting into BDD, let's recap Test Driven Development(TDD) .

<span>Test-driven development  (TDD) refers to a style of programming in which you do  coding, unit testing </span><span>and code refactoring . </span><span>Here's a graphical representation of Test Driven Development</span>

<a href="https://msdnshared.blob.core.windows.net/media/2017/10/TDD_Global_Lifecycle.png"><img width="1421" height="840" class="alignnone size-full wp-image-177" alt="" src="https://msdnshared.blob.core.windows.net/media/2017/10/TDD_Global_Lifecycle.png" /></a>
<p style="text-align: right">(By <a href="Xarawn&amp;action=edit&amp;redlink=1" class="new" title="User:Xarawn (page does not exist)">Xarawn</a> - <span class="int-own-work" lang="en">Own work</span>, <a href="https://creativecommons.org/licenses/by-sa/4.0" title="Creative Commons Attribution-Share Alike 4.0">CC BY-SA 4.0</a>, <a href="https://commons.wikimedia.org/w/index.php?curid=44782343">Link</a>)</p>
This is already a very good approach and is used universally across all technologies and frameworks.Then why BDD ??
<blockquote> Imagine the test cases you generate is the documentation of how your application works,reflecting the user stories or scenarios.So BDD is TDD but with different way of writing the test cases. I would like to call it as  next step of  <span>Test Driven Development(TDD).</span></blockquote>
We will be using a library called <a href="http://specflow.org/">specflow </a>for doing BDD. How to start with specflow can be found <a href="http://specflow.org/getting-started/">here  </a>.

&nbsp;
<ul>
 	<li>Create a Simple Class Library project</li>
 	<li>Add NUnit and Specflow</li>
</ul>
<pre><span>Install-Package SpecFlow.NUnit</span></pre>
<ul>
 	<li>Install the Specflow <a href="https://marketplace.visualstudio.com/items?itemName=TechTalkSpecFlowTeam.SpecFlowforVisualStudio2017">extension </a>for Visual studio</li>
 	<li>Get an understanding on <a href="https://github.com/cucumber/cucumber/wiki/Gherkin">Gherkin </a>Format and how to write a simple spec</li>
 	<li>To Run the tests in Visual Studio,install <a href="https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter">NUnit Test Adapter</a></li>
 	<li>Once you have installed Specflow VS extension, Add a new Feature file and start writing tests.</li>
</ul>
More details can be found <a href="http://specflow.org/getting-started/">here </a>
<h3>Clean/Onion Architecture - create a asp.net mvc/webapi  project with clean/Onion architecture</h3>
Clean/Onion architecture is simple and extensible architectural approach you can easily approach to any project you start. At the center of it is your dependency injection and then everything revolves around it.So you may have a bunch of projects like this imagine your project name is <strong>Contoso</strong>
<ul>
 	<li>Contoso.Core</li>
 	<li>Contoso.Infra</li>
 	<li>Contoso.Web</li>
</ul>
You can also have additional cs projects ,there's been lot of talk on clean or onion architecture and you will find slight variations in different approaches but the core idea remains the same, please refer any of this link below

<a href="https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html">https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html</a>

<a href="https://medium.com/@stephanhoekstra/clean-architecture-in-net-8eed6c224c50">https://medium.com/@stephanhoekstra/clean-architecture-in-net-8eed6c224c50</a>
<h3>Implement a CI/CD pipeline</h3>
I have two implementation one on Azure Team Services and Another on Appveyor. The reason why appveyor is to easily give a public link like this

<a href="https://ci.appveyor.com/project/rohithkrajan/finreconcile/build/tests">https://ci.appveyor.com/project/rohithkrajan/finreconcile/build/tests</a>

I also have a wiki created in github for this

<a href="https://github.com/rohithkrajan/FinReconcile/wiki/CI-CD-Pipeline">https://github.com/rohithkrajan/FinReconcile/wiki/CI-CD-Pipeline</a>

<span>An end to end build ,test and deploy pipeline is setup using VSTS and Azure app Services platform .</span>In our case,I have not implemented automatic deployment from Appveyor because it is already done in Team Services .But you can see build and test in Appveyor.
<h3>Generate Living documentation from BDD specs</h3>
To generate docs , We will be utilizing a library called <a href="http://www.picklesdoc.com/">PicklesDoc</a>

We can also integrate this with our CI/CD pipeline step using the package <a href="https://www.nuget.org/packages/Pickles.MSBuild/">https://www.nuget.org/packages/Pickles.MSBuild/</a>
<pre><span>Install-Package Pickles.MSBuild</span></pre>
<span>This package includes the MSBuild task and a build target that is automatically added to your .csproj.After installing this package,you can add following task to your csproj file</span>
<pre><span class="hljs-tag">&lt;<span class="hljs-title">PropertyGroup</span>&gt;</span><span> 
</span><span class="hljs-tag">&lt;<span class="hljs-title">Pickles_Generate</span>&gt;</span><span>True</span><span class="hljs-tag">&lt;/<span class="hljs-title">Pickles_Generate</span>&gt;
</span><span> </span><span class="hljs-tag">&lt;<span class="hljs-title">Pickles_DocumentationFormat</span>&gt;</span><span>dhtml</span><span class="hljs-tag">&lt;/<span class="hljs-title">Pickles_DocumentationFormat</span>&gt;
</span><span> </span><span class="hljs-tag">&lt;<span class="hljs-title">Pickles_OutputDirectory</span>&gt;</span><span>C:\Temp\MyDocumentation</span><span class="hljs-tag">&lt;/<span class="hljs-title">Pickles_OutputDirectory</span>&gt;
</span><span> </span><span class="hljs-tag">&lt;/<span class="hljs-title">PropertyGroup</span>&gt;
</span></pre>
<span class="hljs-tag">The docs will be generated on the folder you specify Output directory. </span>

So living documentation helps when your project grows in complexity and size.The advantages are
<ul>
 	<li>Anyone can refer the documentations of your project for features Business users or Quality Analysts</li>
 	<li>Documentations will not go out of sync as it is generated from the code itself</li>
 	<li>Helps easily gives a mental picture of any complex piece of component in a step by step way</li>
</ul>
<blockquote>Going through the document generated is easier  when any new developer joins the project and may be he will become productive on day one :)</blockquote>
Hope this helps  with your next project especially if you are given an opportunity to start from scratch :) .But nothing stops you from improving a part of your complex project to BDD ,add a little documentation  or follow little bit of refactoring to implement a good clean or Onion architecture,isn't it ?]]></content:encoded>
    </item>
    <item>
      <title>500.19 error or 502.5 error when hosting asp.net core 2 application inside IIS</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/500-19-error-or-502-5-error-when-hosting-asp-net-core-2-application-inside-iis</link>
      <pubDate>Tue, 13 Mar 2018 11:45:32 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=245</guid>
      <description><![CDATA[While deploying asp.net core 2 to IIS, you may get one of these errors  or both  :)
500.19 Internal...]]></description>
      <content:encoded><![CDATA[While deploying asp.net core 2 to IIS, you may get one of these errors  or both  :)
<h3>500.19 Internal Server error</h3>
The first of the issue is 500.19 error when trying to host an asp.net core 2.0 application inside IIS7. What you get might be  something like below

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/aspnetcore-500.19-error-in-IIS.png"><img src="https://msdnshared.blob.core.windows.net/media/2018/03/aspnetcore-500.19-error-in-IIS.png" alt="" width="952" height="378" class="size-full wp-image-255 aligncenter" /></a>

&nbsp;

This one was quite simple,turned out to be ANCM (ASP.NET CORE MODULE) module and related configuration was not correctly recognized by IIS. This can be fixed by installing the <a href="https://aka.ms/dotnetcore-2-windowshosting">.NET Core Windows Server Hosting bundle</a>  .

By installing the .NET CORE Server Hosting bundle ,it added the ANCM module correctly to IIS .When you install the ANCM module,,it will copy dlls and schema files to as follows
<pre>C:\Windows\System32\inetsrv\aspnetcore.dll

C:\Windows\System32\inetsrv\config\schema\aspnetcore_schema.xml</pre>
If you are running IIS application pool on 32 bit ,you should also see it under
<pre>C:\Windows\SysWOW64\inetsrv\aspnetcore.dll.</pre>
It will also add the required configuration changes to ApplicationHost.Config(C:\Windows\System32\inetsrv\config) file.You should see AspNetCoreModule in the <strong>globalModules</strong> section.
<pre> &lt;add name="AspNetCoreModule" image="%SystemRoot%\system32\inetsrv\aspnetcore.dll" /&gt;

</pre>
<h3>HTTP Error 502.5 - Process Failure</h3>
This error will be like this

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/aspnetcore-502.5-error.png"><img src="https://msdnshared.blob.core.windows.net/media/2018/03/aspnetcore-502.5-error.png" alt="aspnet core 502.5 error" width="593" height="449" class="size-full wp-image-265 aligncenter" /></a>

<span>If the ASP.NET Core Module fails to start, a </span><em>502.5 Process Failure</em><span> status code page appears. This can be caused by multiple reasons</span>
<ul>
 	<li><span>ASP.NET Core Module fails to launch the backend process - This could be because an exception occured in your asp.net core startup.cs </span></li>
 	<li><span>The backend .NET Core process starts but fails to listen on the configured port - You can refer my other <a href="https://blogs.msdn.microsoft.com/rohithrajan/2017/08/27/how-to-fix-the-error-port-is-currently-used-by-another-application/">blog entry</a> for a similar issue</span></li>
</ul>
<blockquote>Please note that if you have <code class="">disableStartUpErrorPage</code><span>  setting enabled, you will just get regular 502 error page of IIS and not this specific page </span></blockquote>
You web.config will be
<pre> &lt;system.webServer&gt;
 &lt;handlers&gt;
 &lt;add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /&gt;
 &lt;/handlers&gt; 
 &lt;aspNetCore processPath="dotnet" arguments=".\web.api.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true" /&gt;
 &lt;/system.webServer&gt;

</pre>
<h3>Step 1 : Look for std log files with failure or enable developer exception page</h3>
stdoutLogEnabled should be enabled and look for a log files in the stdoutLogFile location you specified in your web.config file. <strong>If this folder is not there,do create the folder</strong> and reproduce the issue .

The Logs should appear like
<pre>D:\WebSite\logs&gt;dir
03/13/2018 02:41 PM &lt;DIR&gt; .
03/13/2018 02:41 PM &lt;DIR&gt; ..
03/13/2018 02:40 PM 34,421 stdout_22056_201831391033.log
03/13/2018 02:41 PM 126,180 stdout_22056_201831391038.log
03/13/2018 03:47 PM 1,165,245 stdout_22056_201831391121.log</pre>
<blockquote>&nbsp;</blockquote>
<span class="hljs-tag"><b>If you do not want to look into the log file by login into the server or does not have access to server </b></span>

<span class="hljs-tag">you can just add <span class="hljs-string">ASPNETCORE_ENVIRONMENT environment variable and also enable developer exception page in your startup.cs to see the exception right in browser
</span></span>
<pre><span class="hljs-tag">
&lt;<span class="hljs-name">aspNetCore</span> <span class="hljs-attr">processPath</span>=<span class="hljs-string">"dotnet"</span> <span class="hljs-attr">arguments</span>=<span class="hljs-string">".\MyApp.dll"</span> <span class="hljs-attr">stdoutLogEnabled</span>=<span class="hljs-string">"false"</span> <span class="hljs-attr">stdoutLogFile</span>=<span class="hljs-string">"\\?\%home%\LogFiles\stdout"</span>&gt;</span><span> 
</span><span class="hljs-tag">&lt;<span class="hljs-name">environmentVariables</span>&gt;
</span><span> </span><span class="hljs-tag">&lt;<span class="hljs-name">environmentVariable</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"ASPNETCORE_ENVIRONMENT"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Development"</span> /&gt;</span><span> </span><span>
</span><span class="hljs-tag">&lt;/<span class="hljs-name">environmentVariables</span>&gt;</span><span> 
</span><span class="hljs-tag">&lt;/<span class="hljs-name">aspNetCore</span>&gt;</span></pre>
<span class="hljs-tag">and the startup.cs Configure method should have</span>
<pre>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
if (env.IsDevelopment())
 {
 app.UseDeveloperExceptionPage();
 }</pre>
<span class="hljs-tag">After this,you should see the developer exception page in your application which should tell you what is the error your application is running into.</span>
<h3>Step 2 : if step 1 did not help, check if dotnet.exe can be successfully launched  outside IIS</h3>
Although we run a single application with asp.net core inside IIS,you are actually running two web servers behind the screen.

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/asp.net-core-module-under-the-hood.png"><img src="https://msdnshared.blob.core.windows.net/media/2018/03/asp.net-core-module-under-the-hood.png" alt="asp.net core module under the hood" width="788" height="258" class="alignnone size-full wp-image-295" /></a>

As shown in the above image, Say you have IIS website running on www.example.com which will be listening on port 80. and by default dotnet.exe launches on port 5000. So from IIS website ANCM will proxy the request to dotnet.exe process.So the failure is basically dotnet.exe process is running or IIS could not launch the process. So  we can easily test to verify if the dotnet.exe process is launching without IIS
<ul>
 	<li>Open command prompt as Administrator</li>
 	<li>In command prompt, go to the location where you have published the files and run  <strong>dotnet &lt;web api dll name&gt;</strong></li>
</ul>
<pre>D:\WebSite&gt;dotnet web.api.dll
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
 User profile is available. Using 'C:\Users\rkolakka102716\AppData\Local\AS
P.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys a
t rest.
Hosting environment: Production
Content root path: D:\WebSite
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.</pre>
If you see this message "Application started" ,you can see that your application is working fine outside.But if you get any exception here ,that;s what you are after.
<blockquote>Please note that it is important to run the dotnet.exe &lt;web.ap.dll&gt; as administrator.Otherwise you may see an exception like Unable to Bind URL http://localhost:5000</blockquote>
If you are able to run the dotnet.exe from commandline and browse to the website fine,it means you can run the website successfully outside IIS.
<h3>Step 3: Check Why IIS is not able to launch the dotnet.exe process</h3>
Make Sure Load user Profile setting is true for the application pool identity

<a href="https://msdnshared.blob.core.windows.net/media/2018/03/loaduserprofile_for_application_pool_identity.png"><img src="https://msdnshared.blob.core.windows.net/media/2018/03/loaduserprofile_for_application_pool_identity.png" alt="set load user profile true for applicationpoolidentity" width="440" height="542" class="size-full wp-image-305 aligncenter" /></a>

&nbsp;

If you have not set this setting,<a href="https://blogs.msdn.microsoft.com/rohithrajan/2017/10/08/quick-reference-iis-application-pool/">application pool identity </a> which is running the w3wp.exe  was not able to find the dotnet.exe process.

Hope it helps!]]></content:encoded>
    </item>
    <item>
      <title>Quick Reference : ASP.NET and Windows Authentication</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/quick-reference-asp-net-and-windows-authentication</link>
      <pubDate>Wed, 18 Oct 2017 07:30:48 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=165</guid>
      <description><![CDATA[Authentication is a process by which the system validates a user's logon or sign-in information. A...]]></description>
      <content:encoded><![CDATA[Authentication is a process by which the system validates a user's logon or sign-in information. A user's name and password are verified and if found correct , access is granted . Windows Authentication is a very complex topic and this post will help you learn a quick overview of windows authentication with Asp.net .
<blockquote>Windows authentication (formerly named NTLM) is a secure form of authentication used in intranet environment to authenticate windows users against Microsoft Active Directory. Now  windows users(also called as NT users) are any user created by administrators such as mydomain/bob, euro/Alice for login into your machine.Think fo Active Directory is a place where all the users,passowords etc are stored and this is setup again by Administrators.</blockquote>
Say you are a developer of an application which should be used over intranet by all the people in your company .In this case ,  Windows authentication can be used to authenticate your company's internal users aka Domain users  to your  asp.net application .So the flow will be like

(1) Domain user(e.g. mydomain/username)  =&gt;(2) ActiveDirectory (e.g. MyDomain)=&gt;   (3)ASP.NET website
<ol>
 	<li>any domain user or a local user e.g. mydomain/rohith ,machinename/Bob</li>
 	<li>this step happens transparently without you doing any configuration or code as a developer</li>
 	<li>Configure windows authentication in your asp.net/website.</li>
</ol>
<strong>To configure windows authentication, you can refer this article on <a href="https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/authentication/windowsauthentication/">windows authentication</a> or <a href="https://www.iis.net/configreference/system.webserver/security/authentication/windowsauthentication?showTreeNavigation=true">this </a>.Or with Asp.net specific refer this <a href="https://support.microsoft.com/en-in/help/323176/how-to-implement-windows-authentication-and-authorization-in-asp-net">KB article</a></strong>

Windows authentication supports two authentication protocols, Kerberos and NTLM .But in Configuration you will see 3 setttings Negotiate, Kerberos, and NTLM .Negotiate, is a wrapper for Kerberos  and NTLM, allows the client application to fallback to NTLM if Kerberos is not supported. When you install and enable Windows authentication on IIS 7+ , the default setting is Negotiate.
<p class="lf-text-block lf-block">Windows authentication(You can choose NTLM or Keberos in the IIS settings) can be used under following circumstances :<span class="lf-thread-btn"> </span></p>

<ul class="lf-text-block lf-block">
 	<li>Client computers and Web servers are in the same domain.
<ul>
 	<li>There is no firewall or proxy in between and this is best case scenario where your users will  be able to authenticate using the same login they used to access their machines.</li>
</ul>
</li>
 	<li>Users are required to access the application over internet
<ul>
 	<li>you can make windows authentication work over internet over NTLM but this is not recommended  .</li>
 	<li>Kerberos requires that the client have a direct connection to Active Directory, which is generally not the case in Internet scenarios</li>
</ul>
</li>
</ul>
References :

<a href="https://technet.microsoft.com/en-us/library/cc732841(v=ws.11).aspx">https://technet.microsoft.com/en-us/library/cc732841(v=ws.11).aspx</a>

<a href="https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/authentication/windowsauthentication/">https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/authentication/windowsauthentication/</a>

<a href="https://www.iis.net/configreference/system.webserver/security/authentication/windowsauthentication?showTreeNavigation=true">https://www.iis.net/configreference/system.webserver/security/authentication/windowsauthentication?showTreeNavigation=true</a>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Quick Reference : IIS Application Pool</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/quick-reference-iis-application-pool</link>
      <pubDate>Sun, 08 Oct 2017 05:37:09 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=145</guid>
      <description><![CDATA[What is IIS Application Pool?
IIS runs any website you configure in a process named w3wp.exe. IIS...]]></description>
      <content:encoded><![CDATA[<h4>What is IIS Application Pool?</h4>
<blockquote>IIS runs any website you configure in a process named w3wp.exe. IIS Application pool is feature in IIS which allows each website or a part of it to run under a corresponding w3wp.exe process. So you can run 100 websites all in a single w3wp.exe or 100 different w3wp.exe. E.g. run 3 websites in same application pool(same w3wp.exe) to save memory usage. ,run 2 different websites in two different application pools so that each can run under separate user account(called application pool identity). run a website in one application pool and a subsite 'website/app' under a different application pool.</blockquote>
<a href="https://msdnshared.blob.core.windows.net/media/2017/10/IIS-Application-Pools.png"><img width="1909" height="588" class="size-full wp-image-155" alt="IIS Application Pools" src="https://msdnshared.blob.core.windows.net/media/2017/10/IIS-Application-Pools.png" /></a>
<h4>Some Important Settings you should know</h4>
<ul>
 	<li><strong>Status</strong> - When you start or stop an application pool, basically you start/stop the website or application.In the background you are starting or stoping the w3wp.exe process which is running your website.</li>
 	<li><strong>.NET CLR Version</strong> - Which version of .NET runtime should be loaded.So if you are deploying asp.net website which should run under .net framework 4.0 or above,you can control that here.# settings
<ul>
 	<li>.NET v2.0</li>
 	<li>.NET v4.5</li>
 	<li>No managed Code - if your application does not have any .net code(asp.net bits) and purely a static website or is a php or nodejs website,you can choose this</li>
</ul>
</li>
 	<li><strong>Managed pipeline</strong> - This is a setting which controls What  request pipeline is used.The request pipeline changed from IIS7+. You have 2 settings
<ul>
 	<li>Integrated - request pipeline introduced from IIS7+ onwards.More details <a href="https://docs.microsoft.com/en-us/iis/application-frameworks/building-and-running-aspnet-applications/aspnet-integration-with-iis">here </a></li>
 	<li>Classic -  IIS6 request pipeline mode.</li>
</ul>
</li>
 	<li><strong>Identity</strong> -This is the application pool identity or simply put this is the user account in which the w3wp.exe will run under.More details <a href="https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities">here </a></li>
 	<li><strong>Applications</strong> - This tells how many websites or applications are running under this Application Pool.</li>
</ul>
<h4>What are the uses of Application Pool ?</h4>
Every website or a part of the website,you can run under an application pool.You can control some basic settings of the website using an application pool.
<ol>
 	<li>You would like the website to run under a different w3wp.exe process.Then create a new application pool and assign that to the website.</li>
 	<li>You would like to run the website and all it's code under a different user account(e.g under Admin privileges),you can run do that by changing <a href="https://technet.microsoft.com/en-us/library/cc771170(v=ws.10).aspx">Application Pool Identity.</a></li>
 	<li>You would like to run a particular application under .net framework 4.0 or 2.0.</li>
 	<li>You would like to make sure the website in 32 bit mode or have a scheduled recycle of the w3wp.exe process etc.All such things are controlled from iis application pool.</li>
</ol>]]></content:encoded>
    </item>
    <item>
      <title>How to fix the error "port is currently used by another application"</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/how-to-fix-the-error-port-is-currently-used-by-another-application</link>
      <pubDate>Sun, 27 Aug 2017 05:16:59 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=75</guid>
      <description><![CDATA[I bet you may have seen this error at least once If you are a web developer  :)

Different error...]]></description>
      <content:encoded><![CDATA[I bet you may have seen this error at least once If you are a web developer  :)

Different error from different tools
<h4>IIS manager gives</h4>
<pre>---------------------------
Internet Information Services (IIS) Manager
---------------------------
This Web site cannot be started. Another Web site may be using the same port.
</pre>
<h4>Apache gives</h4>
<pre>Apache port:443 is being used by another application.</pre>
<h4>Visual Studio</h4>
<pre>Port 10360 is already being used by another application</pre>
So how can we fix this error.There are two parts for this error.
<ol>
 	<li>To find out which program uses this port</li>
 	<li>Does this program really needs to use this port or some other ?</li>
</ol>
<h3>GUI tool approach: Find the processs using port TCPView tool.</h3>
You can use <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/tcpview">tcpview </a>tool from sys internals. This shows all the connections active in the system with which process is using it .

<a href="https://msdnshared.blob.core.windows.net/media/2017/08/tcpview.png"><img width="1876" height="317" class="alignnone size-full wp-image-87" alt="tcpview showing ports used by process" src="https://msdnshared.blob.core.windows.net/media/2017/08/tcpview.png" /></a>

&nbsp;

You can also easily close the connection forcefully and make the port free just by right clicking on a particular connection.

<a href="https://msdnshared.blob.core.windows.net/media/2017/08/close-connection-tcpview.png"><img width="1883" height="690" class="alignnone wp-image-95 size-full" alt="close a connection opened by a process" src="https://msdnshared.blob.core.windows.net/media/2017/08/close-connection-tcpview.png" /></a>

&nbsp;

In the above example, am going to close the connection opened by postgres on port 5432.This can be the port you are looking at where you got the error.
<h3>command line approach: Finding out which program uses this port using netstat command.</h3>
We combine the output of netstat with find command. We are filtering the netstat output with find .
<pre>C:\&gt;netstat -ano |find ":80"
 <span style="color: #000000">TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4</span>
 TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 4
 TCP 176.6.219.84:51311 176.6.57.55:8080 ESTABLISHED 7584
 TCP 176.6.219.84:51351 176.6.57.55:8080 ESTABLISHED 7584
 TCP 176.6.219.84:51383 176.6.57.55:8080 ESTABLISHED 7584
 TCP 176.6.219.84:51462 176.6.57.55:8080 ESTABLISHED 7584
 TCP 176.6.219.84:58672 176.6.57.55:8080 ESTABLISHED 7584
 TCP [::]:80 [::]:0 LISTENING 4
 TCP [::]:8080 [::]:0 LISTENING 4</pre>
&nbsp;
<blockquote>Interpreting the output,you can see the processid in the last column .In our case we have 4 and 7584.That is the process which is using the port.</blockquote>
<pre>TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4</pre>
<ul>
 	<li>TCP is the protocol we are listening on.</li>
 	<li> IP:Port combination 0.0.0.0:80 or [::] means all IP address in this machine we are LISTENING  .More details <a href="https://superuser.com/questions/661188/what-is-in-the-local-address-of-netstat-output">here</a></li>
 	<li>So process id with 4 is listening on 80 and 8080 and you are seeing 4
<pre><span style="color: #000000">0.0.0.0:80 , </span>0.0.0.0:8080 , [::]:80 ,[::]:8080</pre>
<pre></pre>
</li>
</ul>
process with 4 is basically system process.

Now to find out the process ,we can run another command tasklist

C:\&gt;tasklist |find "7584"
chrome.exe 7584 Console 1 144,272 K

process 4 represents System process.

C:\&gt;tasklist|find " 4 "
System 4 Services 0 308 K

Now you know the process,you can go and verify it really needs to use this port or not

&nbsp;
<ul>
 	<li>You can close the connection using TCP view</li>
 	<li>you can stop or kill this particular process. E.g. You have both IIS and Apache installed in one machine and may be some apache website is already using a port you need it.</li>
 	<li>You can reconfigure one process to use another port(e.g. get apache to run under port 8080) or if it is Visual studio,you can go to VS and configure project configuration settings to use another port</li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>When and how does asp.net runtime load  dlls ?</title>
      <link>https://docs.microsoft.com/archive/blogs/rohithrajan/when-and-how-does-asp-net-runtime-load-dlls</link>
      <pubDate>Thu, 29 Jun 2017 06:12:44 GMT</pubDate>
      <dc:creator><![CDATA[Rohith Rajan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rohithrajan/?p=65</guid>
      <description><![CDATA[Let's look at when and how asp.net runtime loads a particular dll. Your asp.net code needs to load...]]></description>
      <content:encoded><![CDATA[Let's look at when and how asp.net runtime loads a particular dll. Your asp.net code needs to load lot of dlls to run your application.When you run your asp.net application/website ,typically it will be under IISExpress (iisexpress.exe) or IIS(w3wp.exe).

For a bare minimum asp.net application without any custom dlls created using a default VS template running under w3wp.exe , Looking at the dlls loaded using <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/">debugging tools for windows </a>, we can see
<ul>
 	<li>24 .NET assemblies</li>
 	<li>35 IIS dlls (C:\windows\System32\inetsrv) - this depends on the IIS installation and modules,handlers configured.</li>
 	<li>62 Windows System libraries(ntdll,kernel32)</li>
 	<li>8 .NET framework dlls (clr.dll,webengine4.dll,mscoreei.dll etc)</li>
</ul>
Note: These numbers can vary based on the version of .NET framework,OS you are running.

You can see a full list of dlls and where it loaded from below windbg output.

&nbsp;
<pre>         Base TimeStamp                     Module
            7ff7ba9d0000 57899b8a Jul 16 07:57:22 2016 c:\windows\system32\inetsrv\w3wp.exe
            7ffdd02d0000 5965abad Jul 12 10:25:09 2017 C:\windows\SYSTEM32\ntdll.dll
            7ffdce0c0000 59028368 Apr 28 05:18:56 2017 C:\windows\System32\KERNEL32.DLL
            7ffdcd3d0000 5965ac8c Jul 12 10:28:52 2017 C:\windows\System32\KERNELBASE.dll
            7ffdd0230000 57899b47 Jul 16 07:56:15 2016 C:\windows\System32\msvcrt.dll
            7ffdcff40000 594a140e Jun 21 12:07:02 2017 C:\windows\System32\combase.dll
            7ffdcd6a0000 578997b5 Jul 16 07:41:01 2016 C:\windows\System32\ucrtbase.dll
            7ffdcd860000 57a558cf Aug 06 08:56:07 2016 C:\windows\System32\RPCRT4.dll
            7ffdcd1e0000 57899aef Jul 16 07:54:47 2016 C:\windows\System32\bcryptPrimitives.dll
            7ffdac080000 57899b15 Jul 16 07:55:25 2016 c:\windows\system32\inetsrv\iisutil.dll
            7ffdce780000 57899904 Jul 16 07:46:36 2016 C:\windows\System32\advapi32.dll
            7ffdcdde0000 57899a7c Jul 16 07:52:52 2016 C:\windows\System32\sechost.dll
            7ffdce5a0000 57dacda4 Sep 15 22:04:44 2016 C:\windows\System32\WS2_32.dll
            7ffdcc7c0000 57899b97 Jul 16 07:57:35 2016 C:\windows\System32\kernel.appcore.dll
            7ffdcbae0000 57899b3a Jul 16 07:56:02 2016 C:\windows\SYSTEM32\ntmarta.dll
            7ffdce610000 584a7939 Dec 09 14:58:25 2016 C:\windows\System32\user32.dll
            7ffdcd840000 57a05800 Aug 02 13:51:20 2016 C:\windows\System32\win32u.dll
            7ffdcff00000 57dace36 Sep 15 22:07:10 2016 C:\windows\System32\GDI32.dll
            7ffdcd250000 59327d2b Jun 03 14:41:07 2017 C:\windows\System32\gdi32full.dll
            7ffdb1b20000 57899bca Jul 16 07:58:26 2016 c:\windows\system32\inetsrv\w3wphost.dll
            7ffdce890000 594a17f6 Jun 21 12:23:42 2017 C:\windows\System32\OLEAUT32.dll
            7ffdcd7a0000 578997a4 Jul 16 07:40:44 2016 C:\windows\System32\msvcp_win.dll
            7ffdac000000 57899a7d Jul 16 07:52:53 2016 c:\windows\system32\inetsrv\nativerd.dll
            7ffdcc2f0000 57899ab7 Jul 16 07:53:51 2016 C:\windows\SYSTEM32\ncrypt.dll
            7ffdc5670000 57899b3a Jul 16 07:56:02 2016 C:\windows\SYSTEM32\XmlLite.dll
            7ffdcc680000 584a7c7e Dec 09 15:12:22 2016 C:\windows\SYSTEM32\bcrypt.dll
            7ffdae830000 578997a1 Jul 16 07:40:41 2016 C:\windows\SYSTEM32\ktmw32.dll
            7ffdcc2b0000 57899b58 Jul 16 07:56:32 2016 C:\windows\SYSTEM32\NTASN1.dll
             2dcb0f50000 57899bc8 Jul 16 07:58:24 2016 c:\windows\system32\inetsrv\IISRES.DLL
            7ffdcc210000 57899b44 Jul 16 07:56:12 2016 C:\windows\SYSTEM32\CRYPTSP.dll
            7ffdcbc10000 57899b12 Jul 16 07:55:22 2016 C:\windows\system32\rsaenh.dll
            7ffdcc230000 57899bc7 Jul 16 07:58:23 2016 C:\windows\SYSTEM32\CRYPTBASE.dll
            7ffdce950000 57899991 Jul 16 07:48:57 2016 C:\windows\System32\clbcatq.dll
            7ffdaeac0000 57899ac6 Jul 16 07:54:06 2016 C:\windows\system32\mlang.dll
            7ffd7f6d0000 594223b0 Jun 15 11:35:36 2017 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\webengine4.dll
            7ffdcde40000 57899a03 Jul 16 07:50:51 2016 C:\windows\System32\PSAPI.DLL
            7ffdb3740000 5849f946 Dec 09 05:52:30 2016 C:\windows\SYSTEM32\MSVCR120_CLR0400.dll
            7ffdcbe90000 57899b1c Jul 16 07:55:32 2016 C:\windows\SYSTEM32\USERENV.dll
            7ffdcc790000 57899b70 Jul 16 07:56:56 2016 C:\windows\System32\profapi.dll
            7ffdbbc90000 578999e5 Jul 16 07:50:21 2016 C:\windows\SYSTEM32\mscoree.dll
            7ffdbbb00000 575a1357 Jun 10 06:39:43 2016 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll
            7ffdce060000 5789988d Jul 16 07:44:37 2016 C:\windows\System32\SHLWAPI.dll
            7ffdbc520000 57899b7f Jul 16 07:57:11 2016 C:\windows\SYSTEM32\VERSION.dll
            7ffd9be30000 593718eb Jun 07 02:34:43 2017 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
            7ffd89570000 5965b173 Jul 12 10:49:47 2017 C:\windows\system32\inetsrv\iiscore.dll
            7ffdb0b20000 57899bbd Jul 16 07:58:13 2016 c:\windows\system32\inetsrv\W3TP.dll
            7ffdcc410000 584a7ca9 Dec 09 15:13:05 2016 C:\windows\SYSTEM32\SspiCli.dll
            7ffd89550000 5789986c Jul 16 07:44:04 2016 c:\windows\system32\inetsrv\w3dt.dll
            7ffdc08e0000 5965b198 Jul 12 10:50:24 2017 C:\windows\SYSTEM32\HTTPAPI.dll
            7ffdc4f60000 57899b54 Jul 16 07:56:28 2016 C:\windows\system32\napinsp.dll
            7ffdc4f80000 57899b21 Jul 16 07:55:37 2016 C:\windows\system32\pnrpnsp.dll
            7ffdca380000 57899a4d Jul 16 07:52:05 2016 C:\windows\system32\NLAapi.dll
            7ffdcc070000 57899a81 Jul 16 07:52:57 2016 C:\windows\System32\mswsock.dll
            7ffdcbdd0000 5965b0e4 Jul 12 10:47:24 2017 C:\windows\SYSTEM32\DNSAPI.dll
            7ffdcdd70000 57899be7 Jul 16 07:58:55 2016 C:\windows\System32\NSI.dll
            7ffdcbd90000 58ba5a9b Mar 04 11:41:39 2017 C:\windows\SYSTEM32\IPHLPAPI.DLL
            7ffdc9f90000 57899b79 Jul 16 07:57:05 2016 C:\windows\System32\winrnr.dll
                58910000 4e5dcc75 Aug 31 11:23:57 2011 C:\Program Files\Bonjour\mdnsNSP.dll
            7ffdc0800000 57899bae Jul 16 07:57:58 2016 C:\windows\System32\wshbth.dll
            7ffdb0f80000 57899bae Jul 16 07:57:58 2016 C:\Windows\System32\rasadhlp.dll
            7ffdc4000000 57899809 Jul 16 07:42:25 2016 C:\windows\System32\fwpuclnt.dll
            7ffdb1b10000 57899b80 Jul 16 07:57:12 2016 C:\windows\System32\inetsrv\loghttp.dll
            7ffd9ec50000 57899bbf Jul 16 07:58:15 2016 C:\windows\System32\inetsrv\cachuri.dll
            7ffd9ec10000 57899bc1 Jul 16 07:58:17 2016 C:\windows\System32\inetsrv\cachfile.dll
            7ffd82c70000 57899bd8 Jul 16 07:58:40 2016 C:\windows\System32\inetsrv\cachtokn.dll
            7ffd82c50000 57899baa Jul 16 07:57:54 2016 C:\windows\System32\inetsrv\cachhttp.dll
            7ffd82980000 57899b98 Jul 16 07:57:36 2016 C:\windows\System32\inetsrv\compdyn.dll
            7ffd82960000 57899b85 Jul 16 07:57:17 2016 C:\windows\System32\inetsrv\compstat.dll
            7ffd82950000 57899bdc Jul 16 07:58:44 2016 C:\windows\System32\inetsrv\defdoc.dll
            7ffd82780000 57899bd2 Jul 16 07:58:34 2016 C:\windows\System32\inetsrv\dirlist.dll
            7ffd82770000 57899bc1 Jul 16 07:58:17 2016 C:\windows\System32\inetsrv\protsup.dll
            7ffd82760000 57899bb9 Jul 16 07:58:09 2016 C:\windows\System32\inetsrv\static.dll
            7ffd82750000 57899b5f Jul 16 07:56:39 2016 C:\windows\System32\inetsrv\authanon.dll
            7ffd82740000 57899bb4 Jul 16 07:58:04 2016 C:\windows\System32\inetsrv\authbas.dll
            7ffd82720000 57899b93 Jul 16 07:57:31 2016 C:\windows\System32\inetsrv\authsspi.dll
            7ffdc8c70000 57899b4e Jul 16 07:56:22 2016 C:\windows\SYSTEM32\wkscli.dll
            7ffdcbe80000 57899bb3 Jul 16 07:58:03 2016 C:\windows\SYSTEM32\netutils.dll
            7ffd82660000 57899bab Jul 16 07:57:55 2016 C:\windows\System32\inetsrv\authmap.dll
            7ffd82650000 57899bb6 Jul 16 07:58:06 2016 C:\windows\System32\inetsrv\modrqflt.dll
            7ffd82640000 58ba6010 Mar 04 12:04:56 2017 C:\windows\System32\inetsrv\custerr.dll
            7ffd7f6b0000 57899b8b Jul 16 07:57:23 2016 C:\windows\System32\inetsrv\iisetw.dll
            7ffd7f680000 57899bac Jul 16 07:57:56 2016 C:\windows\System32\inetsrv\iisfreb.dll
            7ffd7f650000 57899b9c Jul 16 07:57:40 2016 C:\windows\System32\inetsrv\isapi.dll
            7ffd7f630000 57899baf Jul 16 07:57:59 2016 C:\windows\System32\inetsrv\filter.dll
            7ffdccf60000 58ba5a76 Mar 04 11:41:02 2017 C:\windows\System32\shcore.dll
            7ffdcdb30000 594a1722 Jun 21 12:20:10 2017 C:\windows\System32\ole32.dll
            7ffd82630000 57899bdb Jul 16 07:58:43 2016 C:\windows\System32\inetsrv\validcfg.dll
            7ffd7f620000 57899beb Jul 16 07:58:59 2016 C:\windows\System32\inetsrv\warmup.dll
            7ffd7f610000 57899be0 Jul 16 07:58:48 2016 C:\windows\System32\inetsrv\iiswsock.dll
            7ffd7f600000 57899b9a Jul 16 07:57:38 2016 C:\windows\SYSTEM32\websocket.dll
            7ffd7f590000 5540f74f Apr 29 20:52:55 2015 C:\windows\system32\inetsrv\rewrite.dll
            7ffd7f580000 575a1609 Jun 10 06:51:13 2016 C:\windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll
            7ffd7f570000 57899bd9 Jul 16 07:58:41 2016 C:\windows\system32\inetsrv\wbhst_pm.dll
            7ffd7f560000 594223ac Jun 15 11:35:32 2017 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\webengine.dll
            7ffd975d0000 5937153c Jun 07 02:19:00 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\mscorlib\2ef49acbb43c068f6ddf1587283b5f29\mscorlib.ni.dll
            7ffd969a0000 594222b6 Jun 15 11:31:26 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System\51d981c86573c6074d73a12f87da3986\System.ni.dll
            7ffd8d8f0000 59371136 Jun 07 02:01:50 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Core\4d107b26fd5fe2cf378283cf24699d07\System.Core.ni.dll
            7ffd7f780000 594223b3 Jun 15 11:35:39 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web\b1e1919144cbf8786ca79c390642db91\System.Web.ni.dll
            7ffdcc5e0000 578999a8 Jul 16 07:49:20 2016 C:\windows\SYSTEM32\sxs.dll
            7ffd7f540000 59422294 Jun 15 11:30:52 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.8dc504e4#\66442736ce51fd7892a05270e15a946d\System.Web.ApplicationServices.ni.dll
            7ffd9af10000 575a13f8 Jun 10 06:42:24 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Configuration\5e7dd553c9f2940ca72c5afc30a2fe8a\System.Configuration.ni.dll
            7ffd8c9a0000 59371139 Jun 07 02:01:53 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Xml\17b3fd9b9923f2e8da0d5df9dc5b609c\System.Xml.ni.dll
            7ffd9ece0000 593714c5 Jun 07 02:17:01 2017 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll
            7ffd7f4f0000 586fe66a Jan 07 00:18:10 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Runt19c51595#\8e2830e338181c0c201509098765f60d\System.Runtime.Caching.ni.dll
            7ffd7f3e0000 575a1496 Jun 10 06:45:02 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\Microsoft.B83e9cb53#\3ee1a749338e05dc5a6ac40bb868efd0\Microsoft.Build.Utilities.v4.0.ni.dll
            7ffdce9f0000 5980ca88 Aug 02 00:08:00 2017 C:\windows\System32\shell32.dll
            7ffdccf10000 57899b3c Jul 16 07:56:04 2016 C:\windows\System32\cfgmgr32.dll
            7ffdcc830000 594a1598 Jun 21 12:13:36 2017 C:\windows\System32\windows.storage.dll
            7ffdcc740000 57899a1f Jul 16 07:51:19 2016 C:\windows\System32\powrprof.dll
            7ffd7f120000 575a146f Jun 10 06:44:23 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\Microsoft.JScript\70e1cca52f7d5ba5e0f55753338eb4fc\Microsoft.JScript.ni.dll
            7ffd7ef30000 575a13fe Jun 10 06:42:30 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\Microsoft.CSharp\39e569728e57a61c672a402afd2c2063\Microsoft.CSharp.ni.dll
            7ffd88630000 59371adb Jun 07 02:42:59 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Data\bcfb45702eaed659a625f9e582e0c6e9\System.Data.ni.dll
            7ffd882d0000 59371adb Jun 07 02:42:59 2017 C:\windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll
            7ffdcd010000 590280d1 Apr 28 05:07:53 2017 C:\windows\System32\CRYPT32.dll
            7ffdcc7b0000 57899b43 Jul 16 07:56:11 2016 C:\windows\System32\MSASN1.dll
            7ffd7ed10000 575a184c Jun 10 07:00:52 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.Services\1b420f3032bdd53860886e9e15a0271e\System.Web.Services.ni.dll
            7ffd81680000 575a13ff Jun 10 06:42:31 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Drawing\4020667f84c6f2d0cd2f6583db692637\System.Drawing.ni.dll
            7ffd7ec10000 575a15c7 Jun 10 06:50:07 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Ente96d83b35#\5dc5dabf1d2c1c8b2365439b10cd4f65\System.EnterpriseServices.ni.dll
            7ffd7e890000 586fef01 Jan 07 00:54:49 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.IdentityModel\348b87c3df924292a29990830e295620\System.IdentityModel.ni.dll
            7ffd88f30000 586fef04 Jan 07 00:54:52 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Runteb92aa12#\01cc14f75abe10b45fd68595c58ecf2d\System.Runtime.Serialization.ni.dll
            7ffd7d0f0000 586fef27 Jan 07 00:55:27 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.ServiceModel\e36dc787f1a40a0cf4ee8a7219db5f64\System.ServiceModel.ni.dll
            7ffd7cd60000 594222c7 Jun 15 11:31:43 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.28b9ef5a#\85c6da5d659566ab5bc0b8242e6aa5e7\System.Web.Extensions.ni.dll
            7ffdb10d0000 575a13f7 Jun 10 06:42:23 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Xml.Linq\9d61f786f91079fc8e6adc1acf3cc2b3\System.Xml.Linq.ni.dll
            7ffda12f0000 575a1417 Jun 10 06:42:55 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Comp46f2b404#\81a98a7e0fb91b661c064562cb6ede98\System.ComponentModel.DataAnnotations.ni.dll
            7ffd7caf0000 593715d3 Jun 07 02:21:31 2017 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Xaml\1b65c4db6aecbaf2ec4b3bd36ead1286\System.Xaml.ni.dll
            7ffd7ca60000 575a133c Jun 10 06:39:16 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Ente96d83b35#\5dc5dabf1d2c1c8b2365439b10cd4f65\System.EnterpriseServices.Wrapper.dll
            7ffd7cac0000 575a133c Jun 10 06:39:16 2016 C:\windows\Microsoft.Net\assembly\GAC_64\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll
            7ffd7ca10000 575a1416 Jun 10 06:42:54 2016 C:\windows\assembly\NativeImages_v4.0.30319_64\System.Web.82d5542b#\892955b378251d274e472e4c017db003\System.Web.RegularExpressions.ni.dll
            7ffd7ca00000 57899bc9 Jul 16 07:58:25 2016 C:\windows\system32\inetsrv\gzip.dll
            7ffdcbc50000 57899ba3 Jul 16 07:57:47 2016 C:\windows\System32\DPAPI.DLL</pre>
&nbsp;
<blockquote>What we are interested in the above list is when and how asp.net runtime loads those 24 dlls (.NET framework assemblies)  .This number can vary based on your application and that is what we are going to look .The dlls loaded from C:\windows\system32\ and from .NET framework (C:\Windows\Microsoft.NET\Framework64\v4.0.30319) stays same for most of the applications based on the version of .NET framework and OS you are running.</blockquote>
&nbsp;

Following are some of the common scenarios n which your application will try to load a .dll(.NET assembly) into the application.
<ul>
 	<li>Your reference dlls and dependencies of referenced dlls</li>
</ul>
<p style="padding-left: 60px">In your visual studio project file,we will be referring dlls whatever we need.This basically adds an entry into the project file (csproj or vbproj file) like below</p>

<pre style="padding-left: 60px"> &lt;Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"&gt;
 &lt;HintPath&gt;..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll&lt;/HintPath&gt;
 &lt;Private&gt;True&lt;/Private&gt;
 &lt;/Reference&gt;</pre>
&nbsp;
<ul>
 	<li>You are not referring a dll but you can dynamically load the dlls using Reflection
<ul>
 	<li>In your code, You may be using <a href="https://msdn.microsoft.com/en-us/library/system.reflection.assembly.load(v=vs.110).aspx">Assembly.Load</a> or any of it's variants .So at the runtime,this tries to load that assembly and it's dependent assemblies</li>
 	<li>Your configuration(web.config) may be referring that dll .For example you may have any configuration entry which will be using <strong>type</strong>
<pre><code>&lt;log4net&gt; &lt;appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
 &lt;/layout&gt; &lt;/appender&gt;</code></pre>
</li>
 	<li>similarly you may have an httphandler or module configuration where you are loading the type
<pre><code>&lt;httpHandlers&gt;
 &lt;add verb="*" path="test" type="MyHttpHandler.CustomHandler,CustomHandler"/&gt; &lt;/httpHandlers&gt;</code></pre>
</li>
</ul>
</li>
</ul>
&nbsp;
<ul>
 	<li>Another possibility is that you have this dll simply present in your <strong>bin</strong> directory.By default asp.net will try to load all the dlls present in the bin directory because of root web.config(<strong>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config</strong>) setting</li>
</ul>
<pre style="padding-left: 60px"><code>&lt;system.web&gt; &lt;compilation&gt; &lt;assemblies&gt; &lt;add assembly="*" /&gt; &lt;/assemblies&gt; &lt;/compilation&gt; &lt;/system.web&gt;</code></pre>
<ul>
 	<li>This one may be rare,I have seen CLR profilers <a href="https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/profiling/profiling-overview">dynamically inject DLLs</a> to the process.</li>
</ul>
&nbsp;

Hope this helps!]]></content:encoded>
    </item>
  </channel>
</rss>