background preloader

.Net

Facebook Twitter

Simple Error Logging Util Class. Introduction This tip describes a simple exception/custom message logger which can be used to log Application Errors, Logical Errors, etc. in an easy manner.

Simple Error Logging Util Class

Background The importance of having a static mechanism to log these messages came up with below: Repeatedly coded Error logging can be eliminatedIO Errors, etc. needed to be handled while logging errors Using the Code Create the class and its implementation as below: AJAX DLL. Download demo Introduction AJAX DLL is a library developed using .NET for ASP.NET 3.0/3.5/4.0/4.5.

AJAX DLL

It is used to call server side methods from JavaScript. You can pass the method parameter value from JavaScript. Bool To Content Converter. Introduction I've created a lot of bindings to boolean values that required a converter of some kind.

Bool To Content Converter

And, I've found that a simple bool to object converter takes care of a lot of my problems. At first, I would create a user control or converter for just about everything; I've seen a few other people go down that same path. Need to set the background image on a button based on some bool value of the selected item, write a bool to BitmapImage converter. Need to set a text color, based on the success of an operation, write a bool to Brush converter.

Sure, you can also do this with triggers, but if your values keep switching back to their default settings, then you'll need to know a bit about the Dependency Property Value Precedence System that WPF uses to choose the select values of Dependency Properties. Background. New .NET Debugging API Released. Onward and UpwardKeith Ward, Editor in Chief, Visual Studio Magazine Blog archive New .NET Debugging API Released Microsoft's released a new .NET Framework managed library to help with debugging and crash dump analysis.

New .NET Debugging API Released

It's a beta release, and is called Microsoft.Diagnostics.Runtime (abbreviated to ClrMD -- MD for "Memory Diagnostics"). It's available through the NuGet package manager. According to a blog entry by Lee Culver, a developer on Microsoft's .NET Runtime team, it wasn't the original plan to release the library publicly. Culver also noted that the library is a wrapper around CLR internal-only debugging APIs. The most basic thing you'd probably to with ClrMD is print out heap stats to the console. Weekly Digest 11 - Jakub Chodounsky, Programmer. Functional Programming in C# 3.0 using Lambda Expression - Part 1. Introduction C# was born in an object oriented programming family and started evolving to adopt the characteristics from other programming languages as well the functional programming family.

Functional Programming in C# 3.0 using Lambda Expression - Part 1

Cumbersomeness Web.Config. People who are in .NET arena might encounter the plethora of xxx.config files, especially web.config.

Cumbersomeness Web.Config

It is a required devil for placing any configuration settings for your applications. We should appreciate the effort taken by the engineers at Microsoft for introducing (at that time, Java’s configuration approach was very immature) and providing a declarative approach, centralized and optimistic way of configuring your .NET application of any size.

This has fitted well for applications written for simple purpose including training codes, in-house tools, etc. In a real-world, irrespective of small, medium or large scale, both Visual Studio and developers place lots of stuff on this mess surrounded by <, >, />, ” characters. When you see the web.config schema, it accommodates the following types of configuration for an application: Bit sleepy? There are machine wide settings that are overridden by the site and application wide settings too. In the above code, you see such mapping. Domain Specific Language using C# 4.0 - Part 1. Hope you know what DSL (domain specific language) is.

Domain Specific Language using C# 4.0 - Part 1

It is a programming language aimed for a particular domain with the users in that domain in mind. DSL is different from general purpose programming languages (C#, Java, Ruby, Python) in that DSL is limited to a particular problem domain whereas general purpose languages are made for addressing any kind of problems in the world. For example, your NANT build scripts and Unix shell scripts are some of the example DSLs. Yes, DSL is not new. Note that the area for DSL can be financial, maths, science, health-care, space control, etc. A DSL can be created either on top of existing programming languages like C#, Ruby, etc., or created from scratch by using parser-generator tools like ANTLR, Irony. In this article, I create a DSL for examination question paper in C#.

The below diagram depicts the domain model for this domain. Exam Class Question Class CodeProject. How to design exceptions. This article will teach you how you should design your exception classes.

How to design exceptions

It’s a follow up to my previous article which told you what exceptions are and their intended usage. Exception inheritance As C# is an object oriented language exceptions also use inheritance. You might wonder why since exceptions doesn’t benefit from inheritance if you view it from a strict exception handling view. Consider the following code: try { return userFetchedFromDb; } catch (DataException ex) { } ASP.NET News and Articles For Lazy Developers. .NET: Run-time Serialization. Object Serialization in .NET. Piet Obermeyer and Jonathan Hawkins Microsoft Corporation August 2001 Updated March 2002 Summary: Why would you want to use serialization?

Object Serialization in .NET