Posts

How to overcome System.IO.Packaging.Package error while working with OpenXML SDK

Image
Hi, Okay this error will occur when you try to work with OpenXML SDK 2. Now You are added OpenXML dll and added OpenXML related to namespaces to the class...and you are good to build the solution. when you press the Build (F5) Button, Visual studio shows you a crazy error. and most of you try to add System.IO namespace to the solution or calss to overcome this. To be honest in first time I also tried. he he heeeee. but that's not the solution for this error. When you are working with OpenXML namespace this is a very common error and It's not a very complex error. you can fix this problem very easily. so what you have to do is go to project's reference area in the solution explorer and right click to add a new reference then in the reference browser dialog select and add WindowsBase.dll in Framework Assemblies Tab. Okay that's all. press Build (F5) Button again. if you did other things correctly (joking) It'll build smoothly. Have a nice day folks. 

LINQ for Beginners - Part 1

Image
Now I'm going to talk about another Important thing you should learn about when you are dealing with C# language. It's Language Integrated Query (LINQ). here is some point you should know before go to the coding segment. LINQ is set of C# 3.0 language features and framework features for writing  structured type-safety queries over local object collections and remote data sources  LINQ enable query any collection Implementing IEnumerable<>, whether an Array, ArrayList, List or XML Dom or Database Table  LINQ lives under System.LINQ and System.LINQ.Expression namespaces. The basic units of data in LINQ are sequences and elements  A sequence is any object that implements the generic IEnumerable interface and an element is each item in the sequence. This is called a local sequence                     string[] names ={"sam", "John"}; A Query operator is a method that transforms a sequence. A ...

Design Patterns - Part 2 Builder Design Patterns

Image
Hi, Now I'm going to show you another Design pattern you can use for to software design problems you find again and again in real-world application development. This pattern is known as Builder Design Pattern Definition Separate the construction of a complex object from its representation so that the same construction process can create different representations. here is the sample code in c# Main Class  /// <summary> /// Main Class of the Application /// </summary> public class Program { /// <summary> /// Main Method of the Program /// </summary> /// <param name="args"></param> static void Main(string[] args) { // Create director and builders var director = new Director(); Builder builderOne = new ConcreteBuilderOne(); Builder builderTwo = new ConcreteBuilderTwo(); // Construct two products dire...

How to Overcome Microsoft.Office.Interop.Excel errors in Visual Studio 2012

Image
When you are developing Excel Applications in visual Studio 2012 not sure about Visual studio 2010 (didn't have time to check on that) you will get some kind of harsh errors every developer don't want to see....Ha ha joking.. so when These error occurs I'm doing a simple trick to overcome those things. In the below I mention that trick in a step by step manner.  So these are the some of errors you will get when you build the application   To solve these kind of problems you can do various things. you can use Appropriate Application Interface to overcome some problems but when comes to the coding I'm bit lazy....ha ha joke  again.so What I'm doing is Go Project Properties and Change the Target FrameWork to 3.5 or low And remove System.Threading.Tasks namespace from your project. And Rebuild it...It should work smoothly. Hope This will help you.... See you soon.

Design Patterns - Part 1 Abstract Design Pattern

Image
Hello, Today I'm going to explain about something important to all the programmers....hmmm Design patterns...sound familiar? okay before going to the code level let's discuss about these design patterns. so basically design patterns are solutions to software design problems you find again and again in real-world application development. Patterns are about reusable designs and interactions of objects.            The 23 Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. They are categorized in three groups: Creational, Structural, and Behavioral. okay I'm not going to tell much and much boring stuff here. so let's go and learn design pattern one by one. Today I'm going to demonstrate about Abstract Factory Pattern Definition : Provide an interface for creating families of related or dependent objects without specifying their concrete classes. here is the sample code in c# Main Class /// <summary> ...

Dive Deep into XML Deserialization

Image
 I hope you guys read the previous article of mine. which i mentioned about the Advnance XML serialization mechanisms which you can use in your projects to overcome some recurring problems. so now I'm going to show you some generic methods which you can use to slove XML deserialization related problems. Actually I don't have lot of time to explain more about these functions but don't worry I added header comments and inline comment to explain the functionality of these code segments. If you want to know more please comment or message me. Have a nice day guys... see you soon.                         /// <summary> /// This method will convert (deserialize) XML file to a Object collection /// </summary> /// <typeparam name="T"></typeparam> /// <param name="document">The document.</param> /// <param name="rootName">Name of the root.</param...

Dive deep into XML Serialization

Image
Today I'm going to show you some helper methods which will be help you to overcome some problems when you are dealing with XML Serialization.                            /// <summary> /// This method will convert given Object to a XML File /// </summary> /// <typeparam name="T">Type of the Object</typeparam> /// <param name="item">Object which is going to store in XML File</param> /// <param name="rootName">Put Root name if XML Root name is different from it's Original Name</param> /// <returns>XML document with object collection Data</returns> public static XmlDocument SerializeToXml<T>(T item, string rootName) { try { XmlSerializer serializer = null; serializer = string.IsNullOrEmpty(rootName) ? new XmlSerializer(typeof(T)) : new XmlSerializer...