Posts

Showing posts from 2014

Working with NDepend

Image
< Previous NDepend is a software tool which can be integrated with Visual Studio. After successful installation, you can see an NDepend menu option in your Visual Studio menu bar. Most of the sub-menu may be disabled. Here, I have integrated NDepend with MS Visual Studio 2010. To work with, select menu: NDepend > NDepend Start Page The start page will display solution analysis link and can be look like as shown in figure below. To analyze your project and solution, click on link “Analysis VS Solutions and VS Projects”. It will pop up a child window which will display all solution files available in your system. You can select any solution file or can browse a solution from “Browse” button and then click OK. In next window, it may ask to choose an assembly from list of assemblies. For this just click on “Analyze .Net 4 assembly” button, now you can see all the sub-menus have been activated. Dashboard: The dashboard will displa

Software Quality Assurance (QA) and NDepend

Background: Software quality is not limited to testing for strong validations, security and vulnerabilities but also depends upon its architecture, coding standards, and defined business logics. Quality assurance (QA) generally does by separate quality team in software industries and qualifies it after validations, security, vulnerabilities and performance testing. Testers do not have any idea about coding standards and business structures used behind the scene. Now the question arises, if coding guidelines and business structure are not defined properly then does the software will be really a quality product? Object oriented (OO) concepts are not a piece of cake. Understanding, coding and managing software program in object oriented paradigm (OOPs) is really a big challenge in software development. Consider you are the lead of a project and numbers of programmers are programming. Your assigned project is really big, then how you will assure about its quality in terms

Error: The type or namespace name 'Ajax' does not exist in the namespace System.Web.Mvc

ASP.Net MVC ERROR: The type or namespace name 'Ajax' does not exist in the namespace 'System.Web.Mvc' (are you missing an assembly reference?) Solution: Right click on respective referenced .dll, go to 'Properties', set property Copy Local = True, and then rebuild.

Error: Entity framework "Cannot convert from 'System.Data.Objects.ObjectParameter' to 'System.Data.Entity.Core.Objects.ObjectParameter"

Entity Framework ERROR: Cannot convert from 'System.Data.Objects.ObjectParameter' to 'System.Data.Entity.Core.Objects.ObjectParameter[]' entity framework 6 This is one of most frequent compile time error you may face in Entity Framework. This is because either of: 1. Version conflict or 2. Namespace used. By default, while compiling project, framework includes namespace using System . Data . Objects ; Solution: To fix this issue: If version conflicts, install package for respective version of EF. If version is same, change the above namespace to  System . Data . Entity . Core . Objects  

Read excel file using C# and .NET

Image
With C#, we can read excel file data and can store it into DataTable object easily. To do this, you may need to install and prepare development environment as well in the system wherever you want to deploy this application. This is one of the probable solution and is not limited to. Also, I have developed and tested this in Windows environment only, no idea about other OS. Development environment: OS Windows 7 32bit, VS 2012, Excel 2013. Prerequisites: 1. Download and install " Data Connectivity Components ". 2. Register msexcl40.dll located in C:\Windows\System32 3. Register oledb32.dll located in C:\Program Files\Common Files\System\Ole DB Create an excel file. Here, I have created with name Test.xlsx as shown in figure below. Lets move to C# code. To work with excel file, you need an OledbConnection object to communicate with the .xls/.xlsx file. OLEDB (Object Linking and Embedding, Database) is an API designed by Microsoft to access

Debugging windows service in .NET without process attachement

Image
This concept is not developed by me. I got it over the net while working with my windows service and found really good. Therefore, I wish to share it with you. Hope you will love it and can debug your windows service without attaching any process. The complete article can be read here . The same code, given below, I have pasted in Program.cs and I could debug my service as a normal application.

HTTP Error 500.21 - Internal Server Error: ExtensionlessUrlHandler-ISAPI-4.0_32 bit has a bad module

Image
HTTP Error 500.21 - Internal Server Error Handler "ExtensionlessUrlHandler-ISAPI-4.0_32bit" has a bad module "IsapiModule" in its module list Solution: By changing following settings with IIS and .config file, you can fix this issue. Step: 1. Reorder the handlers in your .config file and make ExtensionlessUrlHandler-ISAPI-4.0_64bit as default.                                                   Step: 2. Set framework version to "ASP.Net v4.0" in application pool it has assigned. I could resolved my issue with these two changes.

Session management in ASP.Net MVC and C#

In ASP.NET MVC, we can manage session by four ways: Default , Disabled , ReadOnly and Required . By default, or if we do not provide a session mode, it is set to its Default mode. Session mode is defined in “SessionStateBehavior” class. To set session mode of a controller, we can use “SessionState” attribute at the beginning of defined controller class. For example: [ SessionState (System.Web.SessionState. SessionStateBehavior . Default )] public class HomeController : Controller { } As we are defining the session mode of a particular controller, so its scope is limited to the respective controller only. Off course, for different controller we can set its different session mode. Default mode has with its default and limited functionalities. Disabled mode restricts to store value in session. ReadOnly mode allows to read the session values but does not allow to write a value into session. Required mode allows to both read and write. (This tutorial wr

Creating DOM in jQuery

Image
Document Object Model in HTML or XML is a well-formed document with HTML tags or XML elements. With jQuery, we can create DOM using ‘ createElement () ’ method. Many times, while programming, there may situations arise when you have part of HTML in string format and need to query it to find a particular value of tag, defined in it. In such cases DOM plays a vital role to achieve it. Mechanism is simple, first create a DOM object with HTML string and then find for the element in the DOM object. In jQuery, you can create DOM object as: var dom = document.createElement( 'div' ); While programming, I got trapped in a situation where I need to find ‘span’ tag value on click event of a ‘div’ element. The scenario was, it was bound with a nested ‘div’ and was returning complete element having multiple HTML tags and I had to find single value – Transaction Number , to display the corresponding detailed information. The same I am sharing here with you. No

C# Most FAQ in Interview

What is the difference between Abstract class & Interface? When to use Interface and when to use Abstract class? What is the scenario for multiple inheritances? Can you give an example? What are differences between IQueryable & IEnumerable? What are the difference between List & IEnumerable? Which is better? What is anonymous type? What is the difference between ‘var’ & ‘dynamic’? Can you explain about dependency injection? What are delegate and multi-cast delegate? What is anonymous method?  What is the lambda expression and expression tree? What is Lazy loading in C#? What is generation mechanism in memory management? What is extension method? What is the difference between finally and finalize? What is a strong name in assembly? What is satellite assembly?  What is delay signing? What are the type of signing in assembly & whats the difference? What are the types of inheritance? Describe all. What is the difference between a class & structure

FAQs in ASP.NET MVC

What is the benefit of Razor w.r.t. ASPX view engine? What are Action Link and Action Result in MVC? Can you list out the different types of action results returned by action method? What are areas in MVC? Does MVC support view state? If not, how can we can manage the same? What are Html helpers? How to create custom data annotation? What is filter in MVC? What are the types of filters in MVC? What is rout table in MVC? What is a view engine? Which is faster: Razor or ASPX? How MVC works to process a new request? What is the difference between MVC and MVVM? What are the difference between ASP.NET MVC and aspx web forms? When you will choose MVC architecture and when to choose ASPX web forms?  What is data annotation? Can you define how can I define custom data annotation? What is view bag, view data and temp data? How you will pass parameters to controllers? What are different techniques to pass parameters from view to controllers? What is the difference between @Ht

ServiceStack - An Introduction

Image
What is a ServiceStack? ServiceStack is an open source, cross-platform for .Net and Mono REST web service framework and can run on both .Net framework as well in Mono platform too. ServiceStack have the flexibility of auto configuration of all standard output formats – XML, JSON, CSV, JSV, SOAP1.1, SOAP1.2 and endpoints –REST, RPC, SOAP without any configuration. It embraces only the concepts of DTO and not RPC concept. Whereas, WCF has the option of both. Service developed in service stack can run in windows environment using .Net framework or in Linux OS with Mono* support. *Mono supported OS are: Linux, Mac OS X, iOS, Sun Solaris, BSD, MS Windows, Nintendo Wii, Sony PlayStation 3 etc. Why ServiceStack? ServiceStack is not instead of WCF for its better performance, but main feature is that it can be deployed and works in cross platform like Windows, Mono, Linux, iOS, Mac OS etc. ServiceStack versus WCF: - WCF can be deployed only windows platform wher

Custom Validation in ASP.Net MVC 4

To implement custom validation in C# ASP.NET MVC4, it needs to inherit “ValidationAttribute” class and overwrite “IsValid” method in your class. For this you need to add namespace System.ComponentModel.DataAnnotations. Here, I am creating a class for my custom password attributes and its minimum length should be of 5 chars and maximum   length should be of 10 chars. I have initialized the values in its constructor and defined the code logic in overridden method “IsValid”. public class PasswordAttribute : ValidationAttribute {             int MinLength;             int MaxLength; public PasswordAttribute( int minLength, int maxLength)         {             this .MinLength = minLength;             this .MaxLength = maxLength;         }             public override bool IsValid( object value)        {             // TODO:                      if (condition_satisfied)                 return true ;             else