Showing posts with label Dot NET. Show all posts
Showing posts with label Dot NET. Show all posts

Tuesday, August 22, 2017

Getting Geo-location with JSon and JQuery


$.getJSON("https://freegeoip.net/json/", function(data) {
    const countryCode = data.country_code;
    const countryName = data.country_name;
    const ip = data.ip;
    const timezone = data.time_zone;
    const latitude = data.latitude;
    const longitude = data.longitude;

    alert("Country Code: " + countryCode);
    alert("Country Name: " + countryName);
    alert("IP: " + ip); 
    alert("Time Zone: " + timezone);
    alert("Latitude: " + latitude);
    alert("Longitude: " + longitude);   
});
Credit goes to original coder..

Thursday, November 26, 2015

What is CLR, CTS, CLS in .NET ?

A Brief Introduction To IL code, CLR, CTS, CLS and JIT In .NET


Before explaining these terminologies, I would like to explain how .NET code gets compiled. The developer writes source code in any .NET language i.e. it may VB.NET or C# or VC+++.NET, etc. The source code is compiled to Intermediate code known as IL code by the respective compilers for example for C# it is csc.exe compiler, for VB.NET it is vbc.exe compiler, etc. This half compiled code is then given to JIT(just in time compiler) by CLR which converts IL code to machine specific instructions which then gets executed. In this way a .NET code gets compiled. For better understanding have a look to following diagram :
IC15013
Now we ll have a close look to above terminologies one by one. We will start from IL code.
  • IL Code : The word IL Code stands for Intermediate Language Code. It is a CPU independent partially compiled code. When we develop our .NET  application, we don’t know in what kind of environment our code will run i.e. on which operating system it will be finally hosted, what will be the CPU configuration, etc. So for this purpose we have IL code which is compiled according to machine configuration. IL code is given by Language compiler which is different for different languages for example csc.exe compiler for C#, vbc.exe compiler for VB.NET, etc.
  • CLR : CLR stands for Common Language Runtime. It is the heart of our .NET Framework. CLR performs following tasks :
  1. Garbage Collection : When we run our .NET application, many objects are created. Garbage collection is a background process which deletes the objects which are not in use by the application and frees memory.
  2. Code Access Security(CAS) and Code Verification(CV) : CLR checks the whether the code has access rights and it is safe and authenticated to be used.
  3. IL to Native Translation : The main task of CLR is to provide IL code to JIT to ensure that code is fully compiled as per machine specification.
  • CTS : CTS stands for Common Types System. In .NET we have various languages like C#, VB.NET, etc. There may be many situations where we want code written in one language to be used in another. In order to ensure that we have a smooth communication between different languages, we have CTS. CTS ensures that datatypes defined in two different languages get compiled to a common data type so that code written in one language can be used by another.
  • CLS : CLS stands for Common Language Specifications. It is a subset of CTS. CLS is a set of rules or guidelines which if followed ensures that code written in one .NET language can be used by another .NET language. For example one rule is that we cannot have member functions with same name with case difference only i.e we should not have add() and Add(). This may work in C# because it is case-sensitive but if try to use that C# code in VB.NET, it is not possible because VB.NET is not case-sensitive.
  • JIT : JIT stands for Just In Timer Compiler. It is the internal compiler of .NET which takes IL code from CLR and executes it to machine specific instructions.

Reference from : Link

Thursday, August 1, 2013

Microsoft Visual Studio "Debug" VS "Release" mode

When we want to deploy our web application to live/local server, then we have two options for making built – Release mode and Debug mode. Both the modes have own importance and characteristics. The details about Release mode and Debug mode are as.

Debug Mode
Developer use debug mode for debugging the web application on live/local server. Debug mode allow developers to break the execution of program using interrupt 3 and step through the code. Debug mode has below features:
  • Less optimized code
  • Some additional instructions are added to enable the developer to set a break-point on every source code line.
  • More memory is used by the source code at run-time.
  • Scripts & images downloaded by webresource.axd are not cached.
  • It has big size, and runs slower.


Release Mode
Developer use release mode for final deployment of source code on live server. Release mode Dlls contain optimized code and it is for customers. Release mode has below features:
  • More optimized code
  • Some additional instructions are removed and developer can’t set a break-point on every source code line.
  • Less memory is used by the source code at run-time.
  • Scripts & images downloaded by webresource.axd are cached.
  • It has small size, and runs fast.


There is no difference in functionality of a debug dll and a release dll. usually, when we compile code in debug mode, we have a corresponding .pdb (program database) file. This .pdb file contains information that enables the debugger to map the generated IL (intermediate language) to source code line number. It also contains the names of local variables in the source code.

The Release mode enables optimizations and generates without any debug data, so it is fully optimized. . Lots of your code could be completely removed or rewritten in Release mode. The resulting executable will most likely not match up with your written code. Because of this release mode will run faster than debug mode due to the optimizations.