Tag: .net

  • Out Of Memory exception when deserializing with JSON.net – Use Streams instead

    Calling an api and deserializing the returned json into a type is something I have to do quite often. I used to use the following: //assume client is an instance of HttpClient – this part isn’t important var response = await client.PostAsync(url, content); //read the response as a string var responseString = await response.Content.ReadAsStringAsync(); //use…

    Continue reading

  • Mocking calls to ApplicationContext.Current.Services

    My current contract involves working on a project based on Umbraco. Unit testing Umbraco, can be a bit tricky, especially given the existence of the static ApplicationContext.Current.Services class, which contains handy references to the Umbraco services – provided by a static type! We can’t mock this. So, I created a little wrapper around this that…

    Continue reading

  • Could not load file or assemebly ‘ceTe.DynamicPDF.Rasterizer.40.x86.dll’

    I ran into this issue when deploying an application that uses the DynamicPDF Rasterizer. After emailing support, who got back to me within the promised 24 hours, they offered some good suggestions. The solution for me was to use the installer provided on their download page, which in turn installs the pre-requisites (Visual C++ distributable)…

    Continue reading

  • .net project unit test naming

    Just wanted to do a quick post on unit test method naming, in particular with .net projects; Most test suites I come across are title cased: public void LikeThis() This annoys me. I find long method names hard to read, and easy to miss detail Example: public void DoesNotReImplementAdditionalInterfaceAlreadyImplementedByInterceptedClass() is not a readable as: public…

    Continue reading

  • Removing $id from JSON returned by WebApi

    If you’re using the default JSON formatter (ie- haven’t set another one up) your outputted JSON may look something like this: [ { $id: “1”, FirstName: “John”, LastName: “Smith”, }, { $id: “2”, FirstName: “Sarah”, LastName: “Harris”, }, { $id: “3”, FirstName: “Michael”, LastName: “Jones”, }, { $id: “4”, FirstName: “Harry”, LastName: “Green”, } ]…

    Continue reading

  • Syntax error using Yahoo YUI Compressor .net port – works using java version

    Recently, I was tasked with creating a minified version of a web applications Javascript files. I settled on the Yahoo YUI Compressor, in particular, the .net port of it When I tried to compress a particular file (the jquery.caret plugin), it would throw up a syntax error. This error only occurred using the .net port…

    Continue reading

  • Incremental / Sequential int IDs with MongoDB using an IdGenerator

    I blogged about using incremental ids with mongodb previously, so have a read of that for more information. Although it’s not ideal, we can use sequential / incremental IDs with MongoDB.Sometimes (when migrating legacy systems for example) we just can’t get away from using ints for id’s. While working on implementing MongoDB with N2CMS recently,…

    Continue reading

  • Joe Blogs Wrapper V2 – Help required

    I’m on the verge of being able to release a second, much improved version of the Joe Blogs WordPress & MetaWeblog API Wrapper. Some very brief details below, and a cry for help (or several cries!) New Features / Improvements Friendlier API Instead of having to deal with the XML-RPC interfaces directly, I’ve added a…

    Continue reading

  • C# – String.Concat vs String.Join

    I had a quick Google search for a comparison between string.concat and string.join, but I couldn’t find anything. Say you want to construct the sentence “The quick brown fox jumps over the lazy dog” This is comprised of 9 words, 8 spaces. Using string.concat: public void CreateSentanceUsingStringConcat() { string space = ” “; string the…

    Continue reading

  • Quartz.net trigger not firing

    I’ve used Quartz.net for a little while – more specifically, around 6 months. I started working with it around the end of October 2009. Irrelevant, you may think, but the important thing here is the time. During winter months, the UK runs on GMT (or UTC+0) During these months, (up until 28th March 2010) my…

    Continue reading

  • Could not load file or assembly ‘ChilkatDotNet2’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

    Whilst setting up an application to run on my local machine (running Vista 64bit) I encountered this error: Could not load file or assembly ‘ChilkatDotNet2’ or one of its dependencies. An attempt was made to load a program with an incorrect format.   Obviously, the application uses ChilKat components, but it would seem that the…

    Continue reading

  • Using JoeBlogs -metaWeblog API Wrapper

    Step 1 Download the latest release of JoeBlogs from Codeplex (Click the Downloads tab, and select the latest download) Step 2 Unzip the contents of the downloaded zip file. (I usually copy DLLs I am going to use into a “lib” folder at the root of my solution) Step 3 Add a reference to BOTH…

    Continue reading

  • C# WordPress Wrapper

    Ok, I’ve barely finished this as a stable release, but I thought I’d post this up any way…. A little open source project I’m working on – Joe Blogs. In a nutshell, it allows easy communication to your WordPress (or other blog) via an xml-rpc interface. Big thanks to the work by Charles Cook at…

    Continue reading

  • String.EndsWithAny and StartsWithAny Extension Method

    It frustrated me that while String provides the StartsWith and EndWith method, it doesn’t provide an EndWithAny. So, if I wanted to see if a particular string started or ended with any specified string, I would have to create my own method to return a true or false. Whilst this is fine, it’s a little…

    Continue reading

  • Session_Start event not firing

    I’ve been scratching my head about this one for sometime… As I’m sure your aware (or you wouldn’t be reading this) in the Global.asax file, we have the following method: protected void Session_Start(object sender, EventArgs e) { } Placing a breakpoint on this method, I attached the debugger, ran up my application, and the breakpoint…

    Continue reading