MohamedG's Log


Warning: DataContractSerializer won’t call your constructor!

Consider the following naïve data contract: [DataContract] public class Data { private int[] array; public Data() { this.array = new int[13]; } public int Length { get { return this.array.Length; } } } It looks ok, right? Let’s use it then: DataContractSerializer serializer = new DataContractSerializer(typeof(Data)); Data data = new Data(); using (MemoryStream stream =… Read more

Filtering Event Log Entries by Event Code

When you filter event log entries bu event code using WMI, you can run a query like the following: “SELECT Message FROM Win32_NTLogEvent WHERE EventCode = 7” And as expected, this will return the entries with event code 7. Now, let’s look at the corresponding C# code, given that you already have a list of… Read more