03 January 2014

C# via Java: Arrays

The one primitive type that hasn’t been covered is the array. An array contains a fixed number of items, and each item is a value of the array’s element type. The array elements are individually indexed starting from zero. In comparison to the other primitive types, which are all value types, arrays are reference types. … Read more
26 November 2013

C# via Java: Primitive types

So, what is a primitive type? According to the Incompleteness Theorem, there will always be things in any mathematical system, and therefore any computational system, that cannot be defined using the rules of that system. These rules form the axioms of that system. For Java and C#, the axioms are the rules of the language … Read more
08 November 2013

C# via Java: Introduction

So, I’ve recently changed jobs. Rather than working in .NET land, I’ve migrated over to Java land. But never fear! I’ll continue to peer under the covers of .NET, but my next series will use my new experience in Java to explore the design decisions made in the development of the C# programming language. After … Read more
03 June 2013

Why unhandled exceptions are useful

It’s the bane of most programmers’ lives – an unhandled exception causes your application or webapp to crash, an ugly dialog gets displayed to the user, and they come complaining to you. Then, somehow, you need to figure out what went wrong. Hopefully, you’ve got a log file, or some other way of reporting unhandled … Read more
28 May 2013

.NET Security Part 4

Finally, in this series, I am going to cover some of the security issues that can trip you up when using sandboxed appdomains. DISCLAIMER: I am not a security expert, and this is by no means an exhaustive list. If you actually are writing security-critical code, then get a proper security audit of your code … Read more
16 May 2013

.NET Security Part 3

You write a security-related application that allows addins to be used. These addins (as dlls) can be downloaded from anywhere, and, if allowed to run full-trust, could open a security hole in your application. So you want to restrict what the addin dlls can do, using a sandboxed appdomain, as explained in my previous posts. … Read more
07 May 2013

.NET Security Part 2

So, how do you create partial-trust appdomains? Where do you come across them? There are two main situations in which your assembly runs as partially-trusted using the Microsoft .NET stack: Creating a CLR assembly in SQL Server with anything other than the UNSAFE permission set. The permissions available in each permission set are given here. … Read more
02 May 2013

.NET Security Part 1

Ever since the first version of .NET, it’s been possible to strictly define the actions and resources a particular assembly can use, and, using Code Access Security, permissions to perform certain actions or access certain resources can be defined and modified in code. In .NET 4, the system was completely overhauled. Today, I’ll be starting … Read more
19 April 2013

Inside Portable Class Libraries

Portable Class Libraries were introduced with Visual Studio 2010 SP1 to aid writing libraries that could be used on many different platforms – the full .NET 4/4.5 framework, Windows Phone, Silverlight, Xbox, and Windows Store apps. You simply select which platforms and versions you want to target, then the available subset of APIs are magically … Read more
18 April 2013

Subterranean IL: ThreadLocal revisited

Last year, I looked at the ThreadLocal type as it exists in .NET 4. In .NET 4.5, this type has been completely rewritten. In this post, I’ll be looking at how the new ThreadLocal works in .NET 4.5. I won’t be looking at all the implementation details, but concentrating on how this type works. Again, … Read more
20 August 2012

Inside the DLR – Invoking methods

So, we’ve looked at how a dynamic call is represented in a compiled assembly, and how the dynamic lookup is performed at runtime. The last piece of the puzzle is how the resolved method gets invoked, and that is the subject of this post. Invoking methods As discussed in my previous posts, doing a full … Read more
03 August 2012

Inside the DLR – Callsite binders

So, we’ve looked at how the C# compiler produces a CallSite object for every dynamic call that is made, and provides it with everything it needs to resolve the call at runtime. How is this information used when the callsite is invoked? To create a CallSite object, you need to pass in an instance of … Read more
23 July 2012

Inside the DLR – Callsites

The DLR was introduced in .NET 4 to allow dynamic languages, like Python or Ruby, to run on the CLR. The DLR is also used by C# 4, released at the same time, to implement dynamic binding via the dynamic keyword. In this post, I’ll be looking at what exactly happens when you issue a … Read more
31 May 2012

PostSharp, Obfuscation, and IL

Aspect-oriented programming (AOP) is a relatively new programming paradigm. Originating at Xerox PARC in 1994, the paradigm was first made available for general-purpose development as an extension to Java in 2001. From there, it has quickly been adapted for use in all the common languages used today. In the .NET world, one of the primary … Read more
29 May 2012

.NET vs Windows 8: Rematch!

So, although you will be able to use your existing .NET skills to develop Metro apps, it turns out Microsoft are limiting Visual Studio 2011 Express to Metro-only. From the Express website: Visual Studio 11 Express for Windows 8 provides tools for Metro style app development. To create desktop apps, you need to use Visual … Read more
04 May 2012

Inside Red Gate – Ricky Leeks

So, one of our profilers has a problem. Red Gate produces two .NET profilers – ANTS Performance Profiler (APP) and ANTS Memory Profiler (AMP). Both products help .NET developers solve problems they are virtually guaranteed to encounter at some point in their careers – slow code, and high memory usage, respectively. Everyone understands slow code … Read more
03 May 2012

Subterranean IL: The ThreadLocal type

I came across ThreadLocal<T> while I was researching ConcurrentBag. To look at it, it doesn’t really make much sense. What’s all those extra Cn classes doing in there? Why is there a GenericHolder<T,U,V,W> class? What’s going on? However, digging deeper, it’s a rather ingenious solution to a tricky problem. Thread statics Declaring that a variable … Read more
16 April 2012

Obfuscation is not a panacea

So, you want to obfuscate your .NET application. My question to you is: Why? What are your aims when your obfuscate your application? To protect your IP & algorithms? Prevent crackers from breaking your licensing? Your boss says you need to? To give you a warm fuzzy feeling inside? Obfuscating code correctly can be tricky, … Read more
28 March 2012

.NET vs Windows 8

So, day 1 of DevWeek. Lots and lots of Windows 8 and WinRT, as you would expect. The keynote had some actual content in it, fleshed out some of the details of how your apps linked into the Metro infrastructure, and confirmed that there would indeed be an enterprise version of the app store available … Read more
26 March 2012

Inside the Concurrent Collections: ConcurrentBag

Unlike the other concurrent collections, ConcurrentBag does not really have a non-concurrent analogy. As stated in the MSDN documentation, ConcurrentBag is optimised for the situation where the same thread is both producing and consuming items from the collection. We’ll see how this is the case as we take a closer look. Again, I recommend you … Read more

Join Simple Talk

Join over 200,000 Microsoft professionals, and get full, free access to technical articles, our twice-monthly Simple Talk newsletter, and free SQL tools.

Sign up