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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
For those interested, myself and a few other people from Red Gate will be going to DevWeek 2012 in London this week. I’ll be mostly around the .NET and C# talks, but may drop into the architecture and agile talks as well. I’ll be blogging interesting stuff I come across as well. If you want … Read more
It is an oft-repeated maxim that you shouldn’t add methods to a publically-released interface in an API. Recently, I was hit hard when this wasn’t followed. As part of the work on ApplicationMetrics, I’ve been implementing auto-reporting of MVC action methods; whenever an action was called on a controller, ApplicationMetrics would automatically report it without … Read more