Posts

Showing posts from 2011

Resharper 6.1 EAP throws an exception upon load

Last night I updated my ReSharper 6.1 EAP extension within VS 11 Developer Preview, I was several builds behind and thought it best to try and stay in sync. Updating is easy enough, however upon restarting Visual Studio I was finding Resharper was throwing exceptions on load and wanted to send information about them "home". I decided to look at the "detailed information" that shows the stack trace and found the following: Could not load file or assembly 'JetBrains.ReSharper.UnitTestFramework, Version=6.1.13.115 It turns out that this was happening in the xunit contrib plugin I had loading for Resharper so I could run my XUnit tests within its runner. For now I rolled back by Resharper version until I get chance to either get the source for XUnit Contrib and fix the issue or someone else does it for me :)

Passing Objects between Silverlight Applications

This week I have been making some prototype applications using Silverlight, which has been awesome, and I decided that I wanted to pass a few objects between these applications. If this wasn't a quick prototype and didn't have to run off of a Sales person's laptop I would have whipped together a quick bit of RIA Services and got them talking that way. However these are just two out of browser applications. Enter Local Messaging. Silverlight has a great little feature, that I'm not sure is too often used, Local Messaging . Local Messaging allows you to send simple string messages between two Silverlight applications running on a local computer. This can be within the same Web Page or two Out of Browser Applications Local messaging works by having a LocalMessageReciever listening for messages in one application and then a LocalMessageSender sending messages from the other. If you want two way communication you simply have a listener and sender in each application. ...

linq to lucene magic unicorn edition

This week I started to look at using Lucene.Net again in a project. Previously I have used it directly however whilst on the new look Lucene.Net website I noticed the linq to lucene project. Which at first look seemed pretty good. However upon looking at the source I found it only works with XML and LinqToSql, this prototype project however was in .Net 4 and used Sql CE4 with Entity Framework 4.1 Code First. Rather than abandon linq to lucene I decided it should be easy enough to get it working with EF4.1. DatabaseIndexSet contains the LinqToSql specific code so for the purpose of producing a proof of concept this is where all the changes go. The first item to change is to rescope the generic where clause to be DbContext rather than the linq context. public class DatabaseIndexSet : IndexSet where TDataContext : DbContext Next the Write Method needs altering, the LinqToSQL implementation uses the GetTable method, however E.F doesn't really have the same meth...

Using the Razor Engine to create PDFs

I've been using MVC 3 and the Razor syntax for a while now, and a while ago whilst reading how people were using Razor for their email templates I had the idea to use Razor to help create PDF templates. Now sadly it's been a while since I played around with this but I have only just started getting back on top of things so here's how I've done it. Components Used My solution is to write HTML templates using the Razor syntax and then to make use of the Razor View Engine for filling in the dynamic data. Then for the PDF creation to make use of iTextSharp library to generating the PDF documents from the generated HTML. iTextSharp is a free library that allows you to create PDF's using C#, unfortunatley its API is a bit of a pain to use natively so I have made use of Hugo Bonacci's HtmlToPdfBuilder.cs class to simply my interaction with the library. The first thing to do is to generate the HTML markup for out PDF. So fire up a new RazorViewEngine and load the v...

Using DeferredLoadListBox in a Pivot Control

Recently I've been using the DeferredLoadListBox It's a fantastic way of improving the performance of your list views. I started using the DeferredLoadListBox within a Pivot control but occasionally found that the app would randomly crash throwing the following exception: All containers must have a Height set (ex: via ItemContainerStyle), though the heights need not all need to be the same. This usually means you haven't set the properly. However I had ensured I had set the style height. I then got the source and started poking around. What I found was although in the UnmaskItemContent method the container had a height if you inspected the ActualHeight property this was 0. I did a bit of research and found the following on MSDN: ActualWidth and ActualHeight are calculated based on the Width/Height property values and the layout system. There is no guarantee as to when these values will be "calculated" So the problem appeared to be with timing. After contactin...

Windows Phone 7: Security Exception on deactivate

This morning I have been finishing the tombstoning part of one of my Windows Phone applications I have been developing. Whilst testing I found that when the application deactivated or terminated that a SecurityException was thrown. Looking at the stack trace I noticed that it was occurring whilst trying to serialise some data to the Applications State store. Now I knew I was putting some data into state so this wasn't to hard to find however, when I looked at what I was putting into state it was nothing more complicated than a custom type that exposed a collection of POCO classes. Why would this cause a security exception. I decided to do a simple Google search for the exception "windows phone 7 security exception" and the second result looked similar: "c# - SecurityException was unhandled when using isolated storage" [ http://stackoverflow.com/questions/4209280/securityexception-was-unhandled-when-using-isolated-storage ]. So I had a look, and guessed that if y...

Windows Phone Development and Designer Exceptions

I've been building a few Windows Phone applications recently and have been learning lot's along the way and am hopefully releasing a couple of these in the near future. However on my current project I have been constantly hounded by the designer view of my xaml pages throwing exceptions. Tonight I decided to finally look into why these occur, I have managed to ignore them previously due to the weird nature of them. My exception scenario consists of a page that contains a pivot control and inside one of the pivot items there is a user control. The user control contains a simple list view which has some data bound to it Now I have always got past the exceptions as if you use the designer view for the user control it works fine, however as soon as I put it into a page or a pivot the designer starts kicking off. The actual exception is as follows: Could not load type 'System.Net.HttpUtility' from assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToke...