.NET

Setting up Slackin using Azure and Let’s Encrypt

So I started the sw-dotnet-developers slack (https://sw-dotnet.uk/) a week or so ago, and quickly realised I needed some kind of self registration system to avoid me having to send off invites to everyone, which would become boring very quickly. I did some searching and found Slackin – a little server that enables public access to a slack server – awesome! It even has an Azure Deploy setup – literally click on one link and fill in some details to get it installed. NB – I had to use the ‘latest’, ......

Cornwall .NET Developer Meetup–FIRST!

Living in Cornwall is great, surf, sun (ha!) and stunning views all over the place – I’m very lucky :) But one thing it does lack – is .NET meetups, in Cornwall – there are approximately none. That’s right – none! Well – no longer! Software Cornwall has created one - https://www.meetup.com/Corn... admittedly this is short notice (it’s this Friday) but – if you’re a .NET developer, and you live in Cornwall, I encourage you to get over there! As a side note – I’ve just started ......

Neo4jClient–Bolt Edition

Neo4j 3.x added a new transport protocol called ‘Bolt’ in essence a binary transmission protocol to speed up connectivity to the database, and with a series of official drivers – get everyone on an even keel. Trouble is, changing from Neo4jClient to Neo4j-Driver is a big pain, for two main reasons: 1. You lose all the fluent setup you get with Neo4jClient (Cypher.Match(“”).Where(“”) etc) 2. You lose all the object mapping (.Return(u => u.As<User>())) Some people would be happy to just be ......

DotNetters–it’s time to graph up

I recently wrote an article with Michael Hunger (of Neo4j) about getting your .NET on with Neo4j - http://thenewstack.io/graph-database-neo4j-net-client/ – it’s time guys, it really is time!

Calling Stored Procs in Neo4j using Neo4jClient –the hacky way

Neo4j 3.0 introduced the concept of Stored Procedures, now, whilst they’re not the same as SQL based SPs, they work – and well – it’s what we’ve got! Neo4jClient doesn’t currently have any native way to call a Stored Proc, so to get you there in the interim, we’ll use the ‘apoc.create.uuids’ proc – which returns a GUID (or multiples) and uses both the CALL and YIELD keywords. (Sorry for lack of code highlighting….) var gc = new GraphClient(new Uri("http://localhost:7474/... gc.Connect(); ......

BrowserStack Visual Studio 2015 Extension

Do you find that you want browserstack but once again, the extension lets you down by not installing into VS2015. Worry not! As with VS2013 (that I wrote about here) it’s a case of editing the vsixmanifest file and targetting a different visual studio version. Download the extension from the VS gallery (here) open it up with 7zip/winzip/windows and edit the extension.vsixmanifest file, change the following lines from: <Installation InstalledByMsi="false" AllUsers="true"> <InstallationTarget ......

The three stages of *my* database choice

Prologue I write and run a website called Tournr, a site to help people run competitions, it helps them organise and register for competitions, keeping the scores online and taking some of the pain of competition management out for them. I began it due to a badly run competition I attended (and ahem ran) a few years ago – and I wanted to make it better for first-timers (like myself) and old-hands alike. This post is about the database decisions and pains I’ve been through to get where I currently ......

Comprehensive redesigns

So, last night I realised that I’d made some bad decisions with the database, structure and naming, so… I’ve now refactored it all, and I’m feeling… hmmm… meh about it. I suspect I will redo it all later, but for now it will do…. I’ve also come to the conclusion that I was maybe trying too much for the initial release, so as a consequence I have removed one part of the project… (which, by-the-by, I intend to have published in a month or so – and yes Andy, that is one month longer than I mentioned ......

Neo4jClient now supports JsonProperty for Sending Cypher

So, you want a demo graph, and you fire up Neo4j, go to the admin (http://localhost:7474/) and then run :play movies This gets you a graph to play around with, and so you head into Visual Studio (or maybe even LinqPad), and you have an urge now to get all the movies in the DB released after the year 2000. A compulsion if you will. So you create your class to get the movies: class Movie{ public string Title { get; set; } public int Released { get; set; }} And run the query you’ve been dreaming of ......

Neo4jClient 1.1.0.1

Big milestone this one, Neo4jClient now supports Transactions, Authentication and some other little changes. Transaction info is all here: https://github.com/Readify/... You can find the connecting stuff here (at the bottom): https://github.com/Readify/... And the other big(ish) change is the change to make the ‘CollectAs’ method return the class type specified (<T>) instead of Node<T>. Big thanks for this go to Arturo Sevilla (https://github.com/arturos... ......

Changing the VS2015 Icon in Windows 8/8.1

So – you install VS 2015, pin the icon to the start bar and ‘whaaaaaa???’ you discover it’s exactly the same Icon as for VS 2013, which is not handy. Luckily, it’s pretty simple to change that bad boy. Step 1 In the start menu, right click on the program you wish to change the icon for, and select ‘Open file location’ (in these pics, I’ve already done the update) Step 2 Right click on the icon and select ‘Properties’ Step 3 Then click on Change Icon Step 4 Pick a new Icon (I used one from: http://www.iconarchive.com/... ......

Neo4j.AspNet.Identity is Back!

In fairness, it was never *away*, but after a brief hiatus - it is being developed again. So changes – it’s moved - https://github.com/cskardon... It’s also been repackaged and nuget-ed, the instructions on the Readme have been updated and the actual database structure is better than before, it’s not all there (of course) but I will accept pull requests and any issues, open up on the github page. I’ll try to do some follow up posts with the db structure, but roughly: ......

Writing Neo4j Console

So, Neo4j Console is now open sourced at: https://github.com/tournr/n... feel free to branch, fix, edit whatever and issue pull requests, or even just have a gander and code review :) I thought I’d write some notes on what I’ve done and why. Let’s split it into 2 main areas, UI and Backend. The UI Extremely simple WPF front end – I mean – it’s only got 3 text boxes! If I’m honest, it’s not what I want – I want to create a console window like the F# console, something which really does act ......

The Neo4j 1.9 to 2.0 Upgrade

So, with Neo4j 2.0 on the near horizon (RC1 out), it seemed appropriate to upgrade all my current codebase from 1.9 to 2.0. Generally, as a rule of thumb, the conversion has been pretty smooth, there are some pre-2.0 gaffs I’ve made which have made it slightly harder than it needed to be – but the ability to use 1.9 cypher in 2.0 db is incredibly useful. So – I’m (as you can probably tell) a .NET developer, which means I use the excellent neo4jclient to perform pretty much all of my interaction with ......

Icon Editing

Finally nearing the release of the app I’ve been working on for a little while now, and we near the final polishing points – Icons etc and a problem with the VS2008 icon editor… The problem being that VS2008 seems to have settings of 4bit icons only… To the rescue comes Paint.NET and the Icon/Cursor Plug-in (both FREE).. This allows you to edit icon files properly, save in 32bit up to 256x256 (which is probably gonna be big enough :)) It’s pretty simple to use – to the effect that I managed to create ......

Upgrading your Neo4J from XXX to 2.2.0–having authorization trouble?

I’ve recently upgraded one of my Neo4J dbs from 2.1.7 to 2.2.0, and instantly ran into troubles with the new Authentication that the db now has. You’ll notice it when you first login to your browser (http://localhost:7474/) and get asked for a login name and password. Of course, you can turn off authentication via the settings (conf/neo4-server.properties) by changing the ‘dbms.security.auth_enabled’ value to false, but now we’ve got it, we should use it! Luckily neo4jclient already allows us to ......

WebJobs QueueTrigger not working?

I’ve just spent quite some time trying to figure this out, you read many good things about WebJobs, and as luck would have it, you’re in the market for some nifty backend processing whenever something is added to a queue, so now seems a good time to take a proper look. So, right click on my web app, and select ‘Add, New Web Jobs’ and create a new WebJob project. Then start adding my code: class Program { static void Main() { var host = new JobHost(); host.RunAndBlock(); } public static void ProcessQueueMessage([QueueT... ......

New Nuget Package for Neo4j Users - Neo4jClient.Extension

The defacto standard for .net users of Neo4j is the Neo4jClient nuget package, if you don’t have that, you’re basically rolling your own connection code, in some cases you might need to, but most of the time, the client will work well. Today I was adding Neo4jClient to a new project, and searched via the Nuget package UI and up popped Neo4jClient.Extension, so, I went to the github repo, read the .md file and thought - I’ll download that bad boy and give it a go. The general gist is to be able to ......

CdnFallbackExpression for JQuery, JQuery.UI, Modernizr and Bootstrap

So, like a total chump, I didn’t really understand what the CdnFallbackExpression on a Bundle actually meant. It didn’t help that pretty much every example you find online shows you what to write for jQuery, but nothing else. With Tournr, I want to use CDN’s where I can for obvious reasons – and so I dutifully tried the jQuery example: var bundle = new Bundle("~/Scripts/jQuery").... bundle.CdnFallbackExpression = "window.jQuery"; bundle.CdnPath = "https://ajax.aspnetcdn.com... ......

BrowserStack Visual Studio 2013 Extension

TIP: Using VS2015? I've got you covered!So, if you download the extension from Visual Studio Gallery (here) you’ll find it won’t install into VS 2013, but it’s easy to fix. Open up your downloaded file using your preferred zip solution (7zip in my case), edit the extension.vsixmanifest file, and change the following lines from: <Installation InstalledByMsi="false" AllUsers="true"> <InstallationTarget Version="11.0" Id="Microsoft.VisualStudio.... /> <InstallationTarget Version="11.0" ......

Neo4jClient with LinqPad

Quite often I want to just try out some code, usually useful when answering a question on StackOverflow, but typically these don’t require a full solution, and it’s a bit heavy handed to whip out Visual Studio for a simple create / match query, so what about LinqPad? One of the most awesome tools for a .NET developer (if you haven’t got it, you should get it). I’m going to assume a few things here: You have got Neo4j running and know the url (if you’ve changed it) You have downloaded and installed ......

Ninjecting Neo4jClient into MVC5/4/3

First, create your new MVC project (or load your existing one!) Then add the Ninject.MVC nuget package: We’ll also want the Neo4jClient package Now we have those two, we can hook it up, first off we need to tell Ninject how to bind to Neo4jClient, I use a Module for this, so add this class to your project (usually I have them in a sub-folder called ‘Modules’ in the App_Start folder – but it can be anywhere):public class Neo4jModule : NinjectModule { /// <summary>Loads the module into the kernel.</summary> ......

Neo4j Console

Hey Hey Super Early adopters, if you’re using Neo4j and you’re a Visual Studio developer (which probably means I’ve just lot 99% of the audience :)) please try Neo4j Console, it’s an extension for Visual Studio 2013 that allows you to make calls to your local (or remote) server instance of Neo4j. So, once you’ve downloaded it – the question I guess is HOW DO I USE THAT!!!?? Opening It Once installed, it finds itself in the ‘View->Other Windows’ menu, it’s called ‘Neo4j Console’, just like the ......

Another day, another blog post update

Gist: https://gist.github.com/csk... I know! Another question on StackOverflow leads to yet another blog post being updated to use the newer Neo4jClient. So here goes: Darko Micics has written a post about using Neo4jClient with C#.Net, and a question has arisen on StackOverflow asking about how to (in effect) do this in the new version of the Neo4JClient – the version where ‘CreateRelationship’ et al have been marked as obsolete. Luckily, this is a pretty simple (twitter-ish) data set ......

Using Neo4j with F# – Cypher 2.0

There’s an excellent post by Sergey Tihon about using Neo4j with F#, written back in March, before Neo4j began the progression into Cypher 2.0. (Gist for this here: https://gist.github.com/csk... Some of the benefits of the newer Neo4jClient versions are the general move away from using Node / NodeReferences and going for a more consistent Cypher only approach, so I’ve updated the code by Sergey to use the 2.0 stuff (as part of the process of answering this StackOverflow question). BTW: ......

Extending Blend for Visual Studio 2013

So, I got a comment yesterday on my post about Extending Blend 4 and Blend for Visual Studio 2012 asking if I knew how to get it working for Blend for Visual Studio 2013.. My initial thoughts were, just change the location to get the blend dlls from Visual Studio 11.0 to 12.0 and you’re all set, so I went to do that, only to discover that the dlls I normally reference, well – they don’t exist. So… I’ve made a presumption that the actual process of using MEF etc is still the same. I was wrong. So, ......

ImageResizer - AzureReader2 with Azure SDK 2.2

So Azure SDK 2.2 came out recently, which means I can open my azure projects in VS 2013 (yay), so I decided to do an upgrade of my MVC4 project to MVC5, I followed this link on how to do the upgrade, and generally things went ok. I fire up my app, and run into a ‘binding’ issue, that AzureReader2 was trying to use Microsoft.WindowsAzure.Stor... Version=2.1.0.0 but alas, it couldn’t find it. I am not the only one (see stackoverflow), and one solution is to run ‘Add-BindingRedirect’ from the Package ......

Neo4JClient – Getting Path Results

So, let’s get this straight off the bat – Craig Brett has written about using the PathResults from Neo4jclient (a .NET REST client to Neo4J), but times have moved on, and there are some specifics I’ve needed to work out with the newer clients (this post – for reference uses Neo4jclient version: 1.0.0.590). The problem I want to get all the nodes and relationships from starting node ‘n’ going out ‘x’ levels. In Cypher – that’s pretty simple: START n = node(2) MATCH p = n-[:RELATION*1..3]-() RETURN ......

Gotcha Got with AzureReader2 and ImageResizer

After my previous post on getting AzureReader2 up and running with ImageResizer – I ran into a problem – I had a page with a foreach on it, where I had a link to each fullsize image. It was all working fine, except for a couple which just wouldn’t work. <a href="/cloud/blah-1/example... src="/cloud/blah-1/example.... /></a> <a href="/cloud/blah-2/hello%2... src="/cloud/blah-2/Hello%20... ......

Extending Expression Blend 4 & Blend for Visual Studio 2012

Just getting this off the bat, I presume this will also work for Blend 5, but I can’t confirm it… Anyhews, I imagine you’re here because you want to know how to create an addin for Blend, so let’s jump right in there! First, and foremost, we’re going to need to ensure our development environment has the right setup, so the checklist: Visual Studio 2012 Blend for Visual Studio 2012 OK, let’s create a new project (class library, .NET 4.5): Hello.Extension The ‘.Extension’ bit is very very important. ......

Neo4J and Azure and VS2012 and Windows 8

Now, I know that this has been written about, but both of the main places (http://www.richard-banks.o... and http://blog.neo4j.org/2011/... utilise VS2010, and well, I’m on VS2012 and Windows 8. Not that I think Win 8 had anything to do with it really, anyhews! I’m going to begin from the beginning, this is my first foray into running something on Azure, so it’s been a bit of a learning curve. But luckily the Neo4J guys have ......

Mocking ITable<T>

I have to do some mocking of an ITable to be able to test some of my code, as you may imagine this is the point where we’re crossing the data boundary… Now, ITable is a total bugger to mock, I’ve tried on (at least) 3 separate occasions to get it mocked, and have only now, finally achieved an 80% solution. (Nothing is ever 100%) I’m not using any mock framework, they just take too long to setup (in this case) and instead have a concrete class that implements ITable and uses an IList as it’s base. ......

InitParams in Silverlight – passed via MVC

The old skool way of passing InitParams in aspx is well documented, adding a: <param name="initParams" value="<%=InitParams%>" /> which is accessing the public ‘InitParams’ member in the code-behind file, which is inevitably set up via the ‘Page_Init’ handler. All well and good, but not practical in MVC, so… how to do this? (NB. This is just how I’ve done it, it’s not the only solution) There are a few things to change: 1. The Model I’ve created a SilverlightHostModel, it only has one ......

Ajaxy

Today is the big day, the day I attempt to use Ajax in the app… I’ve never done this (well, tell a lie, I’ve done it in a ‘tutorial’ site, but that was a while ago now), so it’s going to be interesting.. OK, basics first, let’s start with the @Ajax.ActionLink Right, first stab: @Ajax.ActionLink("Click to get latest", "LatestEntry", new AjaxOptions { UpdateTargetId = "ajaxEntrant", InsertionMode = InsertionMode.Replace, HttpMethod = "GET" }) As far as I’m aware, I’m asking to get the ‘LatestEntry’ ......

Registering…

So, I want potential clients to have to enter the least amount of info possible to get an account, to that end, I really don’t see the benefit of a username and email address, I’d rather just use the email address. Pretty easy, edit the Register.cshtml to remove all traces of a ‘username’ field… Edit the controller so that it now reads: model.UserName = model.Email; if (ModelState.IsValid) { /*...*/ } F5 and … no Hmmm, turns out the ModelState isn’t valid, and that’s down to the fact that I’ve left ......

MVC–Hooking up my randomizer

Structurally, I have 3 projects, the site, the EF database and the randomizer. The randomizer uses entities from the EF database, so all is good on that front. So, first cut, add a method to my Controller called Randomize, which takes in one of the EF entities: public ActionResult Randomize(TableB tableB) { /*...*/ } I’ve even given it an [HttpPost] attribute, now, I’m not anyway sure this is right, time will tell right? Anyhews, simple method: [HttpPost] public ActionResult Randomize(TableB tableB) ......

MVC–Day 2(or 3/4ish, maybe more)

So, my excursion in the web world continues… One of the issues I have coming from silverlight / wpf is that I’m very used to the XAML, MVVM approach to developing, I can knock up a passable interface in XAML in very little time (note, I didn’t say a good interface), but I really don’t know how to do this in CSS.. OK, not totally true, I have a rough guess, I have played with things like Firebug, and modified existing css in the past, but the problem with that, is that I’m just tinkering. With this ......

MVC3–The Beginning

OOook, those who know me, or have read my blog probably have a pretty good idea that I’m a silverlight, wpf, wcf, c#, xamly kinda guy. I’ve never really done anything webby, the closest I’ve gotten is doing a bit of backend stuff, well, times change, and quite frankly I wanted to do something new… soooo I’ve opted to go down the MVC route, for two main reasons – 1, I figured I may as well learn a good framework, 2, Matt Abbott told me that MVC lets you get dirty with HTML, and that’s one of the things ......

MousePath

A while ago, (and by that I mean over a year ago now) I was catching up on the blogs I read and came across this post: http://blog.iso50.com/14644... I thought – Awesomeness! I’ll give that a go… downloaded the app, and ran it, all good – but only on one monitor… :( I work with two monitors, and found that a lot of the time I’d end up with a no lines as I was on the other monitor… So, I thought I’d give it a go and write one myself… I actually had a working version pretty ......

It’s ok to throw System.Exception…

No. No it’s not. It’s not just me saying that, it’s the Microsoft guidelines: http://msdn.microsoft.com/e... Do not throw System.Exception or System.SystemException. Also – as important: Do not catch System.Exception or System.SystemException in framework code, unless you intend to re-throw.. Throwing: Always, always try to pick the most specific exception type you can, if the parameter you have received in your method is null, throw an ArgumentNullException, value received ......

Unknown C# keywords: params

Often overlooked, and (some may say) unloved, is the params keyword, but it’s an awesome keyword, and one you should definitely check out. What does it do? Well, it lets you specify a single parameter that can have a variable number of arguments. You what? Best shown with an example, let’s say we write an add method: public int Add(int first, int second) { return first + second; } meh, it’s alright, does what it says on the tin, but it’s not exactly awe-inspiring… Oh noes! You need to add 3 things ......

Deploying, but without those pesky test files!

Silverlight testing is great, we all know that (don’t we??), we’re expected to do it as part of the development process, but once we’ve got an awesome application written and we come to deploy it, we don’t want the test files going out with it… You might be like me, have the files in a Web project – let’s face it, that’s how we’re pushed into doing it… So let’s stick with it! Now. I’m deploying via the wonders of the Web Deployment shizzle, but this also applies to the classic ‘installer’ project ......

Enum driving a Visual State change via the ViewModel

Exciting title eh? So, here’s the problem, I want to use my ViewModel to drive my Visual State, I’ve used the ‘DataStateBehavior’ before, but the trouble with it is that it only works for bool values, and the minute you jump to more than 2 Visual States, you’re kind of screwed. A quick search has shown up a couple of points of interest, first, the DataStateSwitchBehavior, which is part of the Expression Samples (on Codeplex), and also available via Pete Blois’ blog. The second interest is to use ......

Deployment MSI files on TFS Build Server – The Problem

So, what would seem to be a simple problem, automating the build of an MSI on the TFS build server – using a Microsoft .vdproj setup project type should be a doddle. Add a new build configuration (cunningly called ‘Setup’) ensure it’s building the setup project, create a build configuration to build the ‘Setup’ configuration, and attempt a build! No. Nothing. Works fine locally. Hmmmm Ok, let’s do some quick googling – there appear to be 2 (maybe 3) options: 1. Install VS2010 on the build server ......

Publishing a DeepZoom project to IIS

I’ve just been helping a colleague work out how to publish their Silverlight DeepZoom project to their local IIS instance. Went through the Publish settings in VS2010, published, connected to it via IE and… ah. No Images. OK, no worries, let’s copy the files from the ClientBin folder across that weren’t published… Hmmm, still no joy… Seems to be just the zoom images that aren’t there… Ok, how about trying to access those files.. You get this error when you attempt to access the .dzc file directly: ......

Path Animation in Silverlight

I’ve been spending some time working on prototyping some things I want to get working for a game I’m developing, and one thing I wanted was to get a couple of fly’s flying (buzzing?) around a lightbulb. Ideally I wanted to draw a path and say – Fly – use this path and follow it until the end of time! Turns out in WPF I could do this, but not so in Silverlight. Everything I saw explaining how to do it, involved working out complex (to me) equations to get the motion correct, or using a set of key ......

TFS – Beginnings…

We’ve got TFS installed now, and we’re beginning to test it in the team… At present we’re only using it as a BugTracker / Doc share – and the reason for this is that in 4 weeks (or so) we plan to update the solution to VS2010 (from VS2008) and quite frankly, we can live with our current source control until that point. Aanyhews, so far – so good, aaand (of course) so bad… Coming from the current solution here (Service Desk) it’s a vast improvement, the bugs are (in my opinion) easier to read and ......

NDepend: Application Metrics

A few days (maybe even a week ago now) I had an email in my inbox asking me if I’d like to have a copy of NDepend so I could maybe write something about it on my blog. I went through 3 stages – 1st – free software?! Hell yes, I’ll have that… 2nd, actually, I have Visual Studio 2010, I have code metrics already, do I need more? 3rd – presumably there is a reason that NDepend exists, maybe I should take this opportunity to get to know why and what it’s for. So I said ‘yes’ and the next day I had NDepend ......

Further thoughts on the ObservableCollection extensions

Firstly (thanks Matt) – it should really be an ICollection extension – and so now it is, but also I’ve just ported it to a .NET 4.0 project, and can now make use of optional parameters, and so 3 methods now become 1! /// <summary>Adds a range of items to an <see cref="ICollection{T}"/>.... /// <typeparam name="T">The type held in the <see cref="ICollection{T}"/>.... /// <param name="collection">The <see cref="ICollection{T}"/> instance ......

ObservableCollection Extensions

I’ve had to create a couple of Extensions for the ObservableCollection, (well – I didn’t have to), erm, and so here they are! All are ‘AddRange’ just with different args for different usages.. namespace Extensions { using System; using System.Collections.Generic; using System.Collections.ObjectMo... using System.Linq; /// <summary>Extension methods for the <see cref="ObservableCollection{... class.</summary> public static class ObservableCollectionExtensions { /// <summary>Adds ......

DefaultAppPool - Ha Ha!

I spent a large proportion of yesterday trying to debug why a website I was trying to publish wasn't working.. Upon copying the folder there, and converting it to an application, we browse to the site and lo, nothing there. Not a sausage... Just a blank page. Hours on this.. Is it the web.config? - ahh no. Is it the configuration of the server? - ahh no no. Let's try again, create a new folder... add in a 'Hello world' html page Browse to: Success! ok, Convert to application - Browse to: Failure! ......

XElement case insensitive 'Element' extension

Just a small bit of code, I've been playing around with converting some Xml* code to Linq to Xml code, and pretty successfully achieved everything I wanted, one thing missing was the ability to retrieve an XElement ignoring case. First - I'd like mention that yes I know Xml is case sensitive - and this is a bad thing to do - but I needed to do it due to some wierdness in the input xml... Anyhews, below is the extension method I wrote to deal with this.. public static class XElementExtensions { /// ......

SQL Errror - Token-based validation failed

Soo… Long time no write… A quick project was assigned to me and two other guys at work the other week – one of those quick 2-3 day projects, the ones were speed is paramount. Quality can be worked on after release… Sooo.. 3 parts, 3 of us, we split it 3 ways and all was good – one on database duty (using LINQ to SQL), one on UI (Adobe Flash 10) and me, on WCF service… All was going well, the database was up and running, I was using the libraries to interact it with it without any problems, then we ......

StringFormat annoyances in VS2008

I’ve been using StringFormat in my xaml quite a bit recently, and whilst I’ve liked it, I’ve found that code which is valid tends to cause VS2008 to no longer be able to represent the designer (which some might say is a good thing)… Basically, the following code: <TextBlock Text="{Binding MyValue, StringFormat=The value is {0}}"/> causes VS to basically say ‘no way’ and can no longer render the xaml. Pressing F5 shows the Window just fine… Soo… What can we do about it? If we modify the ‘StringFormat’ ......

WCF and LINQ to SQL (Part 4 – Updates)

If you’ve read parts 1, 2 and indeed 3 you’ll know we’ve covered the CRD of CRUD, today we will cover the ‘U’ – updates! Updates are more complex than the other scenario’s we’ve covered so far, but not unmanageable. Also – in fairness this is a very simple update, more complex updates will require more thought (duh!) but this should be a good starting point. Let’s get to it! We’ll start on familiar ground – updating the interface, adding an ‘UpdateCar’ method: [OperationContract] void UpdateCar(Car ......

WCF and LINQ to SQL (Part 3 (Deletes))

If you’ve read parts 1 and 2 you’ll know we’ve covered the CR of CRUD, today we will cover the ‘D’ – deletions. We’ll need to update our interface to actually provide this functionality: [ServiceContract] public interface ICarsService { [OperationContract] Car GetCar(int id); [OperationContract] void SubmitCar(Car car); [OperationContract] void DeleteCar(int id); } I’ve decided to delete the car via the identifier we created initially, though there is nothing to stop us using a ‘Car’ instance. Anyhews, ......

WCF and LINQ to SQL (Part 2 (Creates))

Right, in my last post I wrote about creating a DBML file and hooking it all up through WCF, however, we only got to ‘retrieving’ from the database via the service. So, let’s presume you want to upload… We already had our contract: [ServiceContract] public interface ICarsService { [OperationContract] Car GetCar(int id); [OperationContract] void SubmitCar(Car car); } Of which we’ve tested the ‘GetCar’ method, let’s get to implementing the ‘SubmitCar’ method. We actually did implement some code in ......

EntitySet.Contains – uses Reference comparisons

A gotcha that got me :) If you’re used to using List<T> collections, and in particular the way they compare, then you need to know that an EntitySet (from LINQ to SQL) does the comparison differently… In my experience, if I’ve created a class, for example: internal class Simple { public int TheInt { get; set; } public string TheString { get; set; } public Simple(int theInt, string theString) { TheInt = theInt; TheString = theString; } } And I then add some instances of this class to a List<Simple>, ......

WCF and LINQ to SQL

Now, I may be doing this wrong, but at the moment, it works :) I’m writing a service to communicate with a database, and provide a consistent front end for the applications that will be using it. In the past that has meant writing tonnes of CRUD (Create Read Update Delete) code, usually via Stored Procs, which are then accessed by a ‘DbAccess’ helper class of some variety. Not to mention the added bonus of writing the classes to store the data as it comes out. Fortunately the database I’m accessing ......

Euler Problem 13 - F#

I finally managed to solve a Euler problem in F# without first resorting to a C# version... That problem? 13... The problem is: "Work out the first ten digits of the sum of the following one-hundred 50-digit numbers." //Numbers all here... Usually, I go for the C# approach first, then see how I can work that into F#, but seeing as I didn't have any 'BigNum' types in C# (and I didn't consider the fact that I only needed to add the first 11 digits of each number - doh!) I dove straight into F#'s 'BigNum' ......

Hunting those elusive Public Folders using Exchange Web Services (Part 3)

In the last two posts (Part 1, Part 2) I've been going over some of the API calls to the Exchange Web Services, and so far we have retrieved an Item, but not any of the attachments held therein... So, lets go get that attachment! We have an ItemType, which lets us know we have attachments, and now will even let us pull some basic properties but not to save... so, how do we save? What we're (well, *I'm*) going to do is get the Item, then if it has attachments, save the attachments to my temp directory, ......

Hunting those elusive Public Folders using Exchange Web Services (Part 2)

In the first of these posts, we created a binding to the Exchange Web Services (EWS) and managed to hunt down our public folder identity. But, as we left it, we're now stuck with just the identity and not anything else. Really, we want the items from inside a given folder, and to do that we need to use the 'FindItems' API call.. FindItems needs a FolderId and of course the our old friend - the ExchangeServiceBinding (see part 1 for how to create that!). Once again, in a familiar pattern, we need ......

SL: Where TF are the Brushes??

Holy Smokes! A SilverLight post???!!! Yes - I've entered the SilverLight realms... so far so good - one app is nearly ready for release (internal only) and I have to say the experience has been pretty good. I've had a couple of issues - mainly down to the fact that I'm not sure about some things - Cross Domain Policies for example... but on the whole it's been ok... One of the things I did struggle with was the programatic setting of brushes, for example, say I wanted to set the Foreground property ......

Databinding an Enum in WPF...

The situation I have is this - I have a class defined as such: public class MyClass { public int TheInt { get; set; } public string TheString { get; set; } public MyEnum TheEnum { get; set; } } with 'MyEnum' defined as: public enum MyEnum { A, B, C, D } I have a Window that displays the data in such a way: <Window.Resources> <CollectionViewSource x:Key="SortedEnumView"> <CollectionViewSource.So... <ComponentModel:SortDesc... </CollectionViewSource.S... ......

Boxing / Unboxing and passing by 'ref'.

I recently heard a question stating something along the lines of: "What is Boxing?" My initial thoughts were the classic example using an ArrayList, whereby storing a value type (int etc) is 'boxed' into an object so the ArrayList can contain it. But the question was followed up with: "Ok, so is this how you think passing a value by ref to a method works?" Personally I hadn't thought about that, I've used 'ref' on numerous occasions, but hadn't really considered how the CLR does this.... So. How ......

Barcamp Brighton 3: Topic chosen

Due to overwhelming responses to my blog (all 2 of you :)) I'm definitely doing a workshop stylee thing on creating ControlTemplates for WPF Buttons in Expression Blend (2.5), and I have my powerpoint loveliness done for a small chat about SCC, in particular branching... I couldn't think of a way to put them together, SCC the WPF Way! sounded nifty, but just seemed too complicated to join together :) So maybe both? Is that allowed.. Gah, first time, we'll see! In terms of topics to see, I'm interested ......

Quick Serialization / Deserialization Helper Method

After discovering some pretty significant serializaton issues in the code base, and approximately 0% testing of the implementation of ISerializable, I've been spending the last couple of days writing tests for the serialization... I've been using the following code to do the serialization, easy to use: MyObject m = new MyObject("Test"); Assert.IsTrue( m.Equals( Serialization.SerializeAndD... m ) ) ); Of course, this uses the 'Serialization' class, which is defined below! using System.IO; ......

MAF PipeLineBuilder with 'params'

More of a note really, but lets (for example) say we've defined a Contract for our Managed Addin Framework (MAF): [AddInContract] public interface ISimpleCalc : IContract { double Add(double x, double y, params double[] theRest); } if we use the PipeLineBuilder to generate the Pipeline for us, we'll find the contact defined in our 'AddInView' and 'HostView' projects as: public interface ISimpleCalc { double Add(double x, double y, double[] theRest); } Which is obviously a problem as we're expecting ......

Local const strings - do they give better performance?

I just installed Resharper 4 (www.jetbrains.com) on my dev machine, and aside from the usual hints etc, there are some new ones, most notably the way it asks to insert a const string locally, for example: private void ShowMessage() { string msg = "Hello!!"; Console.WriteLine( msg ); } ReSharper suggests should be replaced with: private void ShowMessage() { const string msg = "Hello!!"; Console.WriteLine( msg ); } Now, I've never done that in my code in the past, but, presumably there is some performance ......

The decidedly badly named LoadingCircle WPF Control Pt 2

Badly named Loading Circle PT2 ---------------------------... So, in my last post (http://geekswithblogs.net/... I created a square LoadingCircle UserControl, using old skool WinForms multi-threading in the code behind file, and Xamly fun on the front end.. But there were problems (of course there were), firstly, the animation, whilst it *did* move, was a very 'on/off' affair, i.e. the Ellipse was ......

The decidedly badly named LoadingCircle WPF Control Pt 1

Soooo... I've been playing around with WPF for a while now, generally building small apps for peeps at work, or my own stuff, and one of the things that happens in quite a few cases is the dreaded 'data retrieval' phase. During said phase, the app will go into a state of nothingness whilst the data is retrieved, at which point it'll come back and be useable again. Now, we all know the way to keep the UI active is to multi-thread that bad boy, and that's where I'm at. In the app I'm thinking of, whilst ......

Dispose of a WPF UserControl (ish)

I've been playing with WPF a little bit, and quite frankly got a bit stuck, (Meh! Who'd have thought). The problem is as follows: I create a UserControl - we'll call it 'MyUserControl' (wouldn't want to break traditions now would we). In said user control I have a button, that when pressed will fire off a new thread. This new thread will (say) poll a file / service - whatever - every 10 seconds or so, and update a Label accordingly. When I close the app, if the app is polling, then the app won't ......

RoundedButton Button Style (WPF)

So far, I have only one style which I'm currently using on all my buttons, and to be honest, I'm still working on it, but it's been in a pretty stable state of development for a while now, so I thought I'd share it. Let me introduce you to the imaginatively titled: RoundedButton. The above picture shows 3 buttons, the first (top-most) is the bog standard WPF button, no styles applied. <Button Height="30" Width="100" Margin="20">Normal Button</Button> The second two are RoundedButton styled, ......