Wednesday, 14 December 2016


   I started on this issue when I had my WCF service times out when I am trying a normal socket connection. This was running fine in windows 8. We had a keep-alive WCF call which tells the server that the client is still active. For this we need the port sharing to be enabled on the machine. I was on an impression that the port sharing was not working and because of which it fails. From the log I came to a conclusion that the keep alive was failing so this made me doubt the TCP port sharing. But I could also see that when I install visual studio, then the application works. This made me doubt the .net framework. Finally I detected the slow network. This was the real culprit.

Windows 10 comes with a real time protection which scans each packets received across TCP. This slows down the network. The fix for this is to disable the real time protection.

On the windows settings you can find windows defender. You can switch off real-time protection.

But nothing is intended for bad purpose. So let’s not disable it. We have an option of setting the exclusion list. We have to use that to ignore known applications from this real time scanning. This was we can bring the application back to normal.

Friday, 22 July 2016


  It is important that we test an application in all network conditions. This is because we may want to put demand on a system or device and measure its response to determine a system’s behavior under both normal and anticipated peak load conditions. This makes sure that the application is robust enough to handle all the network conditions before we roll out to users. It would be a painful task to do this kind of testing without the help of any software which hook up the adapter and controls the packet flow. In the absence of such software we will have to manually pull the network wires every time. Also this approach won’t help us test the spiky network conditions. To help us in these testing we have a tool which is called Network Emulator for Windows Toolkit (NEWT). In this article we will see how to configure and use Network Emulator Toolkit to test an application in limited network bandwidth.

Network Emulator Toolkit

NEWT is a software-based solution that can emulate the behavior of both wired and wireless networks using a reliable physical link, such as an Ethernet. It is available in a 32 Bits version and a 64 Bits version. You can download this from This is a pretty handy tool which can mimic all the behaviors of a network. It can be configured to setup latency on packets in the network and can be configured to raise random errors and can be configured to not to deliver some packets and many more. Here I will show some of handy features of this tool. But all other functionality will be self-explanatory once you start using this tool.

1. Configure Network Emulator Client for limited bandwidth.

 This setup is relatively simpler. The network emulator has an option to select the network type. We could choose the dial up network so that it allows packets up and down as if we have a dial up network.
Once installed, open the Network Emulator Client in administrator mode. This will open up Network Emulator Client as shown in the figure below. Here you can see the drop down to select the network types. Select the dial up option from it. It then automatically opens up the default configuration for the dial up setup. For this example the only thing which we require is this configuration. Now we have to press the start button and the network emulator will start controlling the packets.

Configure Dial-up

After configuring Dial-up network

2. Configure Network Emulator Client to mimic spiky network which can also drop some packets.

 In order to configure the advanced scenarios, let us see two important configurations in network emulator. These are Link and Filter. Link defines the network behavior when sending and receiving packets. This configuration can be used to configure packet loss, network error, packet latency, bandwidth and spiky network (connect/disconnect). Filter is used to configure the sender and receiver to which the link configuration is applied. With filter configuration you can control whether the link configuration should be applied to all traffic or to traffic from a particular IP. These configuration objects are as shown in the image below.

Configuration options
In order to configure this scenario, we have to first select the network type, let us use the dial-up network this time. You can select this from the drop-down at the top just like the way you did it in the first scenario. This opens up a channel page where the link and filter is configured. Right click on the link object and you can see a pop up window with options for UpStream and DownStream. Both have the same configuration. UpStream defines the network behavior for packets which are send from the local machine and the DownStream defines the other way. When you click on one of these, it opens up a window where you can configure loss, error, latency, bandwidth, and connect disconnect behavior of the network. This is as shown in the image below. The default option is “No” we have to select the appropriate one which we want.

The filter option is set by default. If you want to control the filter, you can right click on it and say delete. Now from the menu in the top bar, select “Configuration” and then select “New Filter”. Here the default option is all network which says the link configuration will be applied to all network cards. You can also see an option of selecting the sender and receiver, you can use this option if you want to control traffic from a particular source. Once configured, you need to press on the start button and it will control the behavior of the network.

Thursday, 4 February 2016


    In this article I will explain in detail how to setup SQLite with EntityFramework. Setting up SQLite and EntityFramework is straight forward but when I tried, it turn out that the version available at the time when this article was written is not really straight forward. So I thought of sharing this in the form of an article. In this article we will see how we could setup a Database First Entity model with SQLite with just a simple table. In this article we will also move the SQLite and EntityFramwork into a separate dll unlike other sample applications. This is to address another scenario which we will see later in this article.

For this article we will be using

  1. Visual Studio 2012
  2. SQLite 3
  3. EntityFramework 6
  4. .Net framework 4.5

Building the application.

    Here in this example we will be having a single visual studio solution with two projects which targets .net framework version 4.5. To start with let us create an application and name it as StockWatch and the framework version should be 4.5. The main application could be any project type. This will be our main project. In my case I have created a WPF project. Now let us create a ClassLibrary project and name it as DataService and the .net framework should be 4.5. This is the project where we will be handling everything related to SQLite and EntityFramework. The main project will just remain as a dumb project which will refer to the DataService project and will fire a call to this project. This is not necessary to get everything up and running but this is to show one scenario while using SQLite which we will find towards the end of this article.

   SQLite is a third party database and there is no inbuilt driver (ADO.Net provider) in .net framework to connect to this database. To connect to the SQLite database, we need an ADO.Net provider (driver) and this is provided by the SQLite website and can be found as a nugget package. System.Data.SQLite is an ADO.NET provider for SQLite. We need it in our project to proceed with SQLite. The name of the nugget package is also System.Data.SQLite. When we install this package, it will also install EntityFramework. This package comes as a complete package for getting everything done with EntityFramework and SQLIte. So let us install this first into our DataService project.

    The prior requirement for this article is that we need an SQLite3 database with a simple table having two fields (id and name). We will now create an EntityFramework model out of this existing database. Currently EntityFramework supports ModelFirst approach but it is expected that they are going to drop ModelFirst approach going forward and we will not find this in EntityFramework7. Moreover SQLite provider for EntityFramework6 (System.Data.SQLite.EF6) does not support creation of table (such feature is not supported till date). So we cannot implement ModelFirst approach with EntityFramework when the database is SQLite. So here we will only address DatabaseFirst approach.

    We will now create a model out of this existing database. To do this, create a new “ADO.Net Entity Data Model” item to the DataService project and name it as “StockModel” and proceed. From the “Choose Model Contents” dialog which pops up, select “EF Designer from database” and proceed. Now on the “Choose Your Data Connection” dialog which pops up, click on the “New Connection” button which pops up another “Connection Properties window”. On the “Data source” section click on “Change” button which will open up another dialog to Change Data Source as shown below. 

    Here we are missing the SQLite Data source in the dropdown. If you can see an entry for SQlite, then you already have everything ready in your machine and you can skip this step. Now if you are also like me, then we need to install an SQLite component for VisualStudio to have it list here. To get this component we have to go to the SQLIte site( and download the appropriate package for the version of visualstudio which we use. In my case I am using VisualStudio 2012 so I will download a package for VisualStudio 2012 as shown in the image below. Also the version of the package should be same as the version of the SQLite nugget package (See Issue 3 at the bottom of this article)


Now install this after downloading. While installing don’t forget to mark the option to install SQLIte component to GAC and to install the designer component for visualstudio. Once installed, please restart your machine. Once done, come back to the step where we were about to change the data source, now you can see SQLite component listed in the list and Select it and proceed.

   Now it will show another dialog asking you to select your data base, here you browse and find the database which you have created. Now when you say OK to this dialog, it will create a model out of your database.

Issue 1

You may get some error at this point like “Unable to determine the provider name for provider factory of type 'System.Data.SQLite.SQLiteFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.”

This is a bug in SQLite provider. Install SQLite nugget package into the project after changing the framework version to 4.0 and later change it to whatever .net framework which you desired. This will be a one time activity and later if you wish to add this package from project which targets 4.5, then also it will work.

Now once you have fixed all issues, and when you create a model, you will get the model diagram as shown above. Now we will try to add some stock into the database using EntityFramework. For this we will create a class file in DataService project as shown below.

public class StockService
   private StockTradeEntities conn;
   public StockService()
    conn = new StockTradeEntities();

  public void AddStock(string stockCode)
    Stock st = new Stock(); = stockCode;

Now refer this project from the main application and fire the method AddStock(). This will add the stock item into database. Here when you try to run the application and when you fire the AddStock method, you will get an error as below.

Issue 2

The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application.

  Now here all of our SQLite setting is added to the app.config file of our main application and it is expected that SQLite dlls must be present in the output folder where we have the app.config file. We could add the nugget package reference to the main application to fix this, but this breaks the convention of a standard application because for an enterprise application, we would expect that functionalities should be moved as separate modules for better maintenance and adding reference to components used in another module to main application doesn’t look nice or it doesn’t make sense. Here what we could do is that we will change the output directory of the DataService project to point to the same output directory of your main application. This way all the dlls referred by your SQLite module project will be available in the same folder where you have your application config file. This way you could fix this issue.

Issue 3

Cannot find the SQLite Data source in visual studio data source list even after installing SQLite component for Visualstudio.

  Here if you are getting this issue, then please make sure that you have added the SQLite nugget package to the project where you are trying to create a model. This step is necessary to have it listed in the visual studio list of data sources. When you add the nugget package, it adds certain entries to the app.config. These entries are necessary for visual studio to list the component in the data source list.

Now this is all about setting up EntityFramework and SQLite. Now you can build more functionality on top of this. :)