Wednesday, August 24, 2016

Problems debugging Silverlight Application

I was unable to successfully debug my silverlight application until I came across the this answer from StackOverflow (worth checking the one above it as well, although it was the 2nd that fixed my issue).

Monday, August 22, 2016

Fixing error Silverlight.Csharp.Targets was not found

If you are facing build errors where some (likely projects that rely on Silverlight) of your projects are not being loaded into the solution, here's what worked for me (I used Visual Studio 2015, but the same should work for 2010):

(The solution is based on what was proposed here).


  1. Go do Programs and Features, select your Visual Studio installation, and run a Modify (if not present, you may be forced to go with Repair). Check the checkbox that mentions Silverlight
  2. Afterwards, when reopening Visual Studio to see if the project(s) is/are correctly loaded - you will be prompted to install Silverlight Developer - the pop-up will include the download link as well. Download, install, and you are (hopefully) done.

Wednesday, August 17, 2016

Visual Studio Web Development Extensions

http://webtooling.visualstudio.com/extensions/web-development

Going up one level, you get into http://webtooling.visualstudio.com, that overviews what visual studio offers in covering the technologies being used today.

P.S.: PowerTools has historically given me freezing problems, making it not an option.

Wednesday, August 10, 2016

Javascript learning resources

I found in Felix Kling's stackoverflow profile 3 really interesting links about learning javascript.

Eloquent JavaScript (free online edition)
You don't know JavaScript (free online edition)
quirksmode.org - especially DOM and event handling

I was surprised to find the sources look very good and are free.

Tuesday, August 9, 2016

Linq OrderBy vs ThenBy - composite ordering calling OrderBy multiple times over is not what you want to do

Do not apply multiple order by linq operators one over the output of the other - the results will not be what you want.



var sequence = new[]
{
    new {a = 10, b = 20, c = 301, d = 1},
    new {a = 1000, b = 50, c = 30, d = 0},
    new {a = 50, b = 10, c = 1130, d = 1},
    new {a = 5, b = 0, c = 130, d = 0},
};

var o1 = sequence.OrderBy(s => s.a);
var o2 = sequence.OrderBy(s => s.b);
var o3 = sequence.OrderBy(s => s.c);

var fluentSyntaxSort = sequence.OrderBy(s => s.a).OrderBy(s => s.b).OrderBy(s => s.c);

var thenBy = sequence.OrderBy(s => s.a).ThenBy(s => s.b).ThenBy(s => s.c);

Console.WriteLine("3 order bys EACH ON THE ORIGINAL sequence");
foreach (var o in o1)
    Console.WriteLine(o);
foreach (var o in o2)
    Console.WriteLine(o);
foreach (var o in o3)
    Console.WriteLine(o);

Console.WriteLine("\nFluent syntax:");
foreach (var o in fluentSyntaxSort)
    Console.WriteLine(o);

Console.WriteLine("\nThenBy:");
foreach (var o in thenBy)
    Console.WriteLine(o);

Output:


Monday, August 1, 2016

.NET's built in methods to convert between distinct numeric representations (supports 2, 8, 10 and 16 only)

Here's something that few seem to know about, but that more than often we are in need of: the .NET's Convert methods can convert to/from the following numeric representations 2, 8, 10, 16.

            var binary = Convert.ToString(30, 2); // 11110
            var bits = binary.ToCharArray().Select(c => byte.Parse(c.ToString())); // a collection of the bits stored in 'binary' above
            var hexa = Convert.ToString(100, 16); //64
            var octa = Convert.ToInt64(12.ToString(), 8); //10 (decimal representation of 12 in base 8 = 10)

Thursday, July 28, 2016

System.Console Right-To-Left Writing

I accidentally revisited this topic today, and was able to answer my "Can .NET's System.Console be configured to print Right To Left?" question from a year ago - here.