Archives by Tag 'C#'

“CleanRiaClientFilesTask” task failed unexpectedly

By admin - Last updated: Thursday, December 16, 2010

If you are getting the following error while compiling Silverlight project, You can try to delete the obj folder under the current project folder and compile again. Error 43 The “CleanRiaClientFilesTask” task failed unexpectedly. System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path) at System.IO.Path.GetDirectoryName(String path) at Microsoft.ServiceModel.DomainServices.Tools.RiaClientFilesTask.<FilesPreviouslyWritten>b__0(String f) at System.Linq.EnumerableSorter`2.ComputeKeys(TElement[] elements, Int32 count) at System.Linq.EnumerableSorter`1.Sort(TElement[] [...]

WCF POX, JSON and SOAP Coexist

By admin - Last updated: Monday, August 16, 2010

Sometimes, we want to make a service available in different protocols so that clients could have an option to choose one of their favorite methods to consume the web services. Here we are going to talk about how to make one WCF service available in POX(Plain Old XML as XML for short), JSON and SOAP [...]

A simplest/dumbest CSharp IDE

By admin - Last updated: Sunday, November 29, 2009

The tiny WPF app (14k) has a textbox allows the input of the C# code, it compiles the code and execute the code after press F5 key. Here is what it looks like. No surprise. The main part which compiles the code at runtime is using CSharpCodeProvider from Microsoft.CSharp namespace. static CompilerResults Build(string code, IEnumerable<string> [...]

C# Find All Derived Types From Assembly

By admin - Last updated: Sunday, November 15, 2009

I was always wondering if there is any method to find all derived types for the given type within an assembly. It would be handy to just pass either a class or an interface type and it will return me all its subs. I’ve come out with a method does that. It finds all the [...]

C# different ways of declaring a delegate

By admin - Last updated: Friday, October 30, 2009

Lambda is quick and sweet. class DelegateTests     {         public void Run()         {             // there are many ways to call method Test             // 1, declare Func<int, string> delegate             [...]

AssemblyResolve FileNotFoundException, Load Assembly from resource

By admin - Last updated: Friday, September 18, 2009

I was struggling with this issue while I was trying to load the referenced assembly stream from the resource. It was caused by JIT (Just In Time compiler) tries to resolve the assembly before the CLR actually executes the AssemblyResolve assignment. You may have the code looks like this static void Main(string[] args) {   [...]

C# Wait for all threads completed with timeout

By admin - Last updated: Friday, July 31, 2009

We only want to do something after all threads finish their work. The advantage is that all the threads can work simultaneously while each of them has no dependency to the other. Typically, I found it improves efficiency when making call to the remove webservice. For example, there is a web service operation called getProductById(int [...]

Exchange Server 2007 WebService, Get Inbox Email Items – C#, SOAP Requests and Responses

By admin - Last updated: Tuesday, May 26, 2009

I was evaluating the Exchange Server 2007 WebService API and trying to get a list of latest inbox items from EWS web service. It took me a while to figure out the request objects and the way to configure all the parameters. Here is the C# code doing this. The ExchangePlay.exws Proxy was generated within [...]

C# StreamReader, StreamWriter default internal FileStream

By admin - Last updated: Monday, April 6, 2009

I was wondering about the default FileStream object configuration within StreamWriter constructor, specifically the FileShare parameter of the FileStream. I’d like to find out if other processes are able to read the content at the same time while StreamWriter writes the content into the file. e.g using (StreamWriter writer= new StreamWriter(“test.txt”)) {      while(true); [...]

WCF Soap11 vs Soap11WSAddressing10 vs Soap11WSAddressingAugust2004 vs Soap12 vs Soap12WSAddressing10 vs Soap12WSAddressingAugust2004

By admin - Last updated: Sunday, February 22, 2009

I’ve done some quick test on WCF interoperability of the SOAP versions and WSAddressing. SOAP 1.1 vs SOAP 1.2 SOAP 1.2 is an extended version of SOAP 1.1, it does everything that SOAP 1.1 offers, SOAP 1.2 provides clear processing model and it is based on XML infoset, it has no dependency on the underlying [...]

XSLT XML transformation vs Object mapping

By admin - Last updated: Monday, February 9, 2009

I’ve run some tests on transformation from one XML schema to the other so that I can compare the performance between XSLT and XmlSerializer with object mapping as well as the Pros and Cons. It appears XSLT transformed my source XML to target XML faster than the object mapping since XSLT doesn’t take the type [...]

C# Polymorphism and Inheritance override the abstract or virtual

By admin - Last updated: Sunday, February 1, 2009

Occasionally, programmers get to explain Polymorphism and Inheritance in .NET, I’ve compiled some typical use cases in case they need to be explained without IDE. We start with IDrawable interface which indicates all its implementations have a Draw method. Geometry abstract class which contains PrintType() that will be called by the specific implementation. Shape class [...]