DCSIMG
.Net 4.0 - Manu Cohen-Yashar's Blog

Manu Cohen-Yashar's Blog

Browse by Tags

All Tags » .Net 4.0 (RSS)
How to write better code with Code contracts PEX and Moles
When I write code I always ask myself how can I make it better. One of the main steps I take to improve my code is write unit tests and use Asserts. All Code is based on assumptions. (i.e. a variable is not null etc). These assumptions must be validated before the code is executed. We all know that and I hope you all do that but still it happens my that code crushes because an assumption I forgot was not validated. I was looking for something to help be to improve my code and then I heard about PEX...
Reading ETW tracing using Event Viewer
I was looking for a tool to read ETW tracing data. It turned out that the tool I need is right under my nose. Event Viewer. The problem was that ETW (using the logman tool) produces etl files that are not readable by Event Viewer. Fortunately there is a trick. I tried to load the etl file by Event Viewer using open saved log and it failed to load. Event Viewer I saved the etl file as an evtx file and now I could see the tracing data. For WCF and WF you do not need the etl file. All you have to do...
Data Contract topology in WCF 4.0 - DataContractResolver
In WCF 3.x, type resolution was done using the “known types” mechanism. During deserialization, when the serializer encounters an instance that isn’t of the same type as the declared type, it inspects the list of declared “known types” to figure out what type to use. As the author of the service, you could annotate your types/methods with the [KnownType] or [ServiceKnownType] attributes to define the list of possible substitutions. (in code or config) Unfortunately, WCF 3.x doesn’t provide an easy...
Using MEF
MEF – Managed extensibility framework is one of the most exciting new technologies brought by the new .Net framework 4.0. Using MEF it is simple to create extensible applications. There are so many extensibility design patterns but non is as simple as MEF. One of the most popular extensibility pattern is the “provider” pattern. You define an interface that a provider should implement and in config you specify the location of the actual provider. On startup someone has to read the config, load the...