Category Archives: C#

  • How to change the log file name of LOG4NET Rolling File Appender dynamically

    Posted on March 20, 2012 by in C#, Dotnet

    In this article I would explain how to change the log file name & path of Log4Net rolling file appender dynamically. Prerequisites If you are not aware of using Log4Net Rolling File Appender, I would recommend you to read my “Log to a file using LOG4NET Rolling File Appender” blog. Step 1: Create a new […]

  • Understanding LOG4NET configuration

    Posted on March 20, 2012 by in C#, Dotnet

    Understanding LOG4NET configuration
    Log4NET is the best thing out there to write data to variety of targets. It provides so many ways to leverage existing framework to customize to your needs. This article describes log4net configuration in detail.
    Where can I download Log4Net from?
    http://logging.apache.org/log4net/download.html
    Configuration:
    Log4Net supports extensive modification of behavior using configuration. In this section, I would describe the configuration format and other attributes. You could specify the log4net configuration in app.config or web.config depending upon if it is a windows/console application or a web application. Log4Net has its own config parser log4net.Config.Log4NetConfigurationSectionHandler which it would use to parse configuration section.
    Example:

    ……

    Post Tagged with
  • How to apply XSLT Transformation to a XML or to a .NET Object

    Posted on March 17, 2012 by in C#, Dotnet

    What is a XSLT (Extensible Stylesheet Language Transformation)? We could use this to transform input XML into any output type (XHTML, TXT etc). XSL describes how the XML document should be displayed. In an XSL transformation, an XSLT processor reads both an XML document and an XSLT style sheet. Based on the instructions the processor […]

    Post Tagged with ,
  • How to create Extension Methods in .NET

    Posted on March 17, 2012 by in C#, Dotnet

    What are extension methods?

    If you want to extend the functionality of an existing class without modifying the type, extension methods is your solution. Even though you create them as static methods you can invoke them as instance methods.

    Why do you need to create an extension method?

    You can extend the existing code without fear of breaking existing functionality. This would be extremely useful when you are working on some thirdpartycode.
    You can write extension methods that apply to interfaces as well. Imagine Microsoft adding all those LINQ methods to ILIST, they would have ended up by modifying the whole implementation.

    Any Limitations?
    You cannot override existing methods of the class. An extension method with the same name and signature as an interface or class method will never be called. At compile time, extension methods always have lower priority than instance methods defined in the type itself.
    It cannot access private variables of the class it is extending.

    Post Tagged with
  • How to manage assembly version numbers in .NET using CUSTOM MS BUILD TASKS?

    Posted on March 15, 2012 by in C#, Dotnet

    Every .NET assembly is identified by a version number. It is stored in its manifest along with assembly name, public key and other dependency information. This information is used to enforce policy restrictions and to differentiate it from other assemblies. Version information is stored in AssemblyInfo.cs file in the following format.

  • How to share objects (types) between multiple Web Services

    Posted on March 14, 2012 by in C#, Dotnet

    More than often you would consume services which share objects. Once you add them as “Web References” to your client project, it loses the context and you would end up having multiple copies of the same object under different namespace.

    Scenario

    1) Create a new ASP.NET WEB SERVICE APPLICATION.
    2) Create two web services Service1. asmx & Service2.asmx
    3) Create a shared class Department.
    4) Create a web method RetrieveDepartment in Service1. asmx
    5) Create another webmethod ModifyDepartment in Service2.asmx which uses the same department
    6) Create a simple ConsoleApplication and add web references to above 2 services.

    Post Tagged with ,
  • How to do custom username assertion in WSE 3.0.

    Posted on March 14, 2012 by in C#, Dotnet

    This article would describe how to write a custom username assertion in WSE 3.0. It is nothing but sending username/password from client to service and service authenticating the same before honoring the request. Article would also describe how to sign & encrypt the SOAP header/body without a fuss. We would extend one or more of the “TurnKey security assertions” provided WSE. Turnkey assertions are nothing but set of security operations packaged by WSE.
    Essentially there are four pipelines in WSE 3.0. We need to inject our custom policy assertions into these pipelines. As simple as that
    1) Sender’s Output Pipe Line :
    2) Sender’s Input Pipe Line :
    3) Receiver’s Input Pipe Line
    4) Receivers Output Pipe Line.

    Post Tagged with ,
  • How to write custom ADO.NET APPENDER for LOG4NET

    Posted on March 12, 2012 by in C#, Dotnet

    Log4NET is the best thing out there to write data to variety of targets. It provides so many ways to leverage existing framework to customize to your needs. This article describes how to write a custom ADO.NET APPENDER for LOG4NET.

    Post Tagged with ,
  • Shallow Cloning and Deep Cloning of object in C#

    Posted on March 12, 2012 by in C#, Dotnet

    This article explains Shallow Cloning and Deep Cloning of object in C# with examples. Sometimes cloning an object sounds like a simple thing but you have to keep so many things in perspective. Consider this scenario. You have retrieved an object by calling an external web service which is a quite expensive call. That object […]

    Post Tagged with , , ,
Page 16 of 16« First...1213141516