C# Archives - Coding Sharp

Tag: C#

Process with an ID #### is not running in visual studio community edition 2015

Process with an ID #### is not running in visual studio community edition 2015

Asp.Net, Asp.Net MVC, C#.Net
Today I was working on a project and my team member has push the changes to repository first time and I get the latest from git. When I tried to run the project I get an error like "Process with an ID #### is not running". It's showing Id number different every time. If I check the error window It showing me an error like below "The program '[3148] iisexpress.exe' has exited with code -1073741816 (0xc0000008) 'An invalid handle was specified'." In browser it's shows me message like "The webpage is not available." I have tried different different solutions and check but non of them fixed my issue. After googling I found some different different solution and finally 1 solution worked for me. So let me show you how to resolve that issues in visual studio. Solution 1. Cl...
Explore the Use of System.Environment Class

Explore the Use of System.Environment Class

Asp.Net, Asp.Net MVC, C# Interview, C#.Net
System.Environment class can not be inherited. It provides valuable information about current platform and environment of the system. It uses to retrieve environment variable settings, version of the CLR and call stack contents etc. It has various methods and property to get the useful information about current working environment. Lets have a look on some of most used properties. Get the Machine Name - To Get the current system's machine name we can use MachineName property of Environment class. For example : Console.WriteLine("Machine Name :" + Environment.MachineName); Get the Current Working Directory - To Get the current working directory we can use CurrentDirectory property of Environment class. For example : Console.WriteLine("Current Directory :" + Environme...
What is the Difference between Build, Rebuild and Clean in Visual Studio?

What is the Difference between Build, Rebuild and Clean in Visual Studio?

Asp.Net, Asp.Net MVC, C# Interview, C#.Net, Difference
If you are a Microsoft Asp.Net Developer then usually you came across this words like Build, Rebuild and Clean. This article gives you explanation about Difference between Build, Rebuild and Clean If you are using Visual studio you might have question that what is difference between Build, Rebuild and Clean ? here we are going to understand the diversity between them. Build Solution : When we build any solution then Visual studio will build/compile all assemblies (Dlls and EXE's) that are changed, it is basically incremental or partial process in which only CHANGED assemblies are compiled if there is no changed assemblies it won't get build Rebuild Solution: It is full compiled case, in which all assemblies (either changed or not) are deleted and recompiled again, irrespect...
What are the Differences between the Debug class and Trace class?

What are the Differences between the Debug class and Trace class?

Asp.Net, Asp.Net MVC, C# Interview, C#.Net, Difference
Debug and Trace both classes are included in Systems.Diagnostics namespace and have very similar methods. The main difference is that call to Debug class is included in Debug mode only while call to Trace class will be included in Debug as well as Release mode also. So in short we can say it is advisable to use Debug at the time of application development, while Trace option is used at the time of application deployment, like we can trace any error and write it into log files etc. What is the differences between a Debug and Release build? When we are building any .Net project there are two configuration we can select 1 is Debug and another is for Release, While we are developing an application default mode is Debug and programmers keeps is Debug mode for debugging code step by ste...
Difference between WCF and Web API

Difference between WCF and Web API

Asp.Net, Asp.Net MVC, C#.Net, Difference
Difference between WCF and Web API WCF Web API WCF ships with .NET Framework only Web API ships with .NET framework as well as open source WCF Supports RESTful services but in limited manner Web API is very ideal to build RESTful services WCF use attribute based programming model Web API maps http verbs to methods WCF supports reliable transaction and messaging Web API doesn't support reliable transaction and messaging WCF supports tcp, udp, http protocol and also custom transport protocol It supports only http protocol WCF uses Operation, Data contracts and services Web API uses routing, controller, action methods etc, same to Asp.Net MVC
Bind DropDownList in Asp.MVC using ViewData object

Bind DropDownList in Asp.MVC using ViewData object

Asp.Net, Asp.Net MVC, C#.Net
In our previous article we have seen how to bind ViewBag object to dropdown list, In this article we will see how to bind ViewData data to dropdown. Remember we can set any kind of data to ViewData like from database, from enum, from range, fixed value etc. Here we will take some fixed Work status list and save it to the ViewData and then in view we will bind ViewData object value to the dropdown as shown in below code snippet. Controller code Razor View code Above code will produce output as below image. You can see in the controller we have created a list of SelectListItem object, and then added 1 by 1 value to list. After adding all the required items to list, we have assigned it to the ViewData object, which we have used in the razor view while rednering drop...
Bind DropDownList in Asp.MVC using ViewBag object

Bind DropDownList in Asp.MVC using ViewBag object

Asp.Net, Asp.Net MVC, C#.Net
In our previous article we have seen how to bind fixed value from view and how to bind Range to dropdown list, In this article we will see how to bind ViewBag data to dropdown. Remember we can set any data to ViewBag like from database, from enum, from range, fixed value etc. Here we will take some fixed country list and save it to the ViewBag and then in view we will bind ViewBag value to the dropdown as shown in below code snippet. Controller code Razor View code Above code will produce output as below image. In the controller if you see we have created a list of SelectListItem object, and then added 1 by 1 value to the list. After adding all the required items to list, we have assigned it to the ViewBag object, In razor view we have used that ViewBag data for ...
Bind DropDownList in Asp.MVC using Range/Fixed value

Bind DropDownList in Asp.MVC using Range/Fixed value

Asp.Net, Asp.Net MVC, C#.Net
In most of the application we are using dropdown to select some value from predefined list of value. Some of them are getting bind from the database table, some of are getting bind using Enum value while some of them are getting bind using some fix value like 1 to 10, or month drop-down 1 to 12. In this article post we will see how to bind drop-down using range value in MVC. Below if the sample code which will bind 2000 to 2014 in year drop-down. above code will produce output as below image. In the above code we have just write a code in view only, there is no server side code. Now in some cases we need to bind some data which are not in particular range like "2000, 2002, 2004, 2006, 2008" or some string type fixed data then we can not use "Enumerable.Range", so how can w...
XmlDocument class

XmlDocument class

Asp.Net, C#.Net
In the previous article we have seen how to write an XML file using XmlWriter class, in this article we will see how to write an XML file using XmlDocument class. Both are writing the XML file only, however when we want to update an existing XML file then XmlDocument class will be easy to use. Because XmlWriter class will use higher memory consumption. Now look at the below sample code Above code will produce below output As we can see, first we have created an object of XmlDocument class. It will be used to create new element and new attribute both using the CreateElement() and CreateAttribute() methods. Each time we will do the same process, what I mean here is if we want to create 3 nodes in the root element developers then we will do use document object 3 times to cre...
Writing XML with the XmlWriter class

Writing XML with the XmlWriter class

Asp.Net, C#.Net
In previous article we have see about writing and reading text document, but now it's time to start dealing with XML file. Anyhow XML is just a plain text, we can simply start writing an XML tags to the file and save it with .xml file extension. But for .net framework it is very easy and safe to handle. For writing an XML file .net framework provides two different options. XMLWriter and XmlDocument, we will see XMLDocument in the next article. In this article we will focus on XMLWriter approach Let's see the basic different between XmlWriter and XmlDocument. XMLWriter uses less memory compare to XmlDocument, that is the only 1 issue if we are writing a vey big file. Another difference is if we are modofing an xml file using XmlDocument, we can read an exisitng file, change it as req...