Thursday, 29 March 2012

Revisting Linq To Lucene

Last July I wrote a blog post about prototyping getting Entity Framework CodeFirst working with Linq To Lucene. I hadn't realised it was quite that long ago but alas time flies especially with a baby.

Anyhow, I never finished the work nor made it "feature" ready or submitted it back to the project, this was partly due to the apparent inactivity. However this week the Linq To Lucene project has become quite active, and as I now need to use the implementation I spent a few hours to finish it. This included working out how to get all the tables off of a DbContext, which involved a bit of reflection magic and then writing some tests to ensure it worked at least how the LinqToSql version had done.

I have now submitted this as a patch, - item id 11857, and hope its available in the main trunk soon, enjoy!

Wednesday, 21 March 2012

Troubleshooting NuGet failing to load

Today I had the unfortunate circumstance for VS2010 to crash whilst I was working, nothing to big I thought, I've had this happen before.

I reopened VS went to open my solution and got the following message:

Microsoft Visual Studio
The 'NuGet.Tools.NuGetPackage, NuGet.Tools, Version=1.6.21215.9133, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' package did not load correctly.


Nuget is smegged :( I immediately thought to uninstall the extension and then reinstall it, same thing happened :(

I then, (looking back this was foolish as NuGet is shared), thought I know I just load it in VS11 that will work, it also errored.

Not cool, the error message however directs you to start VS with logging enabled by using the /log command argument and then to look at the activity log.  The activity log is located in your appdata roaming folder, simply stick %appdata%\Microsoft\VisualStudio\10.0\ActivityLog.xml into run or %appdata%\Microsoft\VisualStudio\11.0\ActivityLog.xml dependant on your VS version. This will then load a load of XML with the VS loading activity in it. After a bit of scrolling I came across this:
    <time>2012/03/21 09:49:33.568</time>
    <description>SetSite failed for packageSetSite failed for package</description>
    <errorinfo>The composition produced a single composition error, with 2 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.   1) '.', hexadecimal value 0x00, is an invalid character. Line 1, position 1. Resulting in: An exception occurred while trying to create an instance of type 'NuGet.VisualStudio.VsSettings'.
Resulting in: Cannot activate part 'NuGet.VisualStudio.VsSettings'.
Element: NuGet.VisualStudio.VsSettings -->  NuGet.VisualStudio.VsSettings -->  CachedAssemblyCatalog
Resulting in: Cannot get export 'NuGet.VisualStudio.VsSettings (ContractName="NuGet.ISettings")' from part 'NuGet.VisualStudio.VsSettings'.
Element: NuGet.VisualStudio.VsSettings (ContractName="NuGet.ISettings") -->  CachedAssemblyCatalog
.........… rest removed due to length .........
The key information here is the invalid character and the NuGet.VisualStudio.VsSettings. This looks like the NuGet.Config is corrupt, the next question is where is it. Turns out this is also in app data %appdata%\nuget\ Once here I opened the file in notepad and found it was empty all bar the Unicode start file character.

To restore the file you just need to put in the location of package sources NuGet should use, the default is:

<?xml version="1.0" encoding="utf-8"?>
    <add key="NuGet official package source" value="" />
    <add key="NuGet official package source" value="" />
Once this was saved I tried running NuGet via the command prompt and got the familiar available commands listing.


A bit of a pain but the experience lead me to learning about the VS activity log which I'm sure will be useful to know in the future. Now time to get back on with my project....

Tuesday, 13 March 2012

Developing with MonoTouch - Day 1 - Setup


So recently I have started a company and been working on a rather large project, initial plans were to use Window 7 or Windows 8 tablets for the "mobile" solution however for various reasons the plan has somewhat changed to now use iPads.

As primarily a .Net developer this was a tough decision but a necessary one. However I often talked about using MonoTouch for doing iOS develop after successfully doing some work with MonoDroid when it was in beta. So this is my solution, use MonoTouch to code as much as possible in C# and then Xcode where necessary.

I thought it would be a good idea to blog my experiences and any insights I gleam during my first few weeks. I have to admit I have never owned a Mac or an iPad so its all very new, although I have used other peoples.

Stage 1 - Order the kit!
First things first the kit, as most of my work won't actually be on the iPad application but on Azure services etc I decided that the Mac Mini was the way to go. I opted for the basic model i5 2.3 Ghz with 500Gb hard disk. However I did go buy 8GB ram, it was only an extra £35. Due to my existing office setup I chose to reuse my monitor, keyboard and mouse and simply switch my usb hub connection when I work on the Mac so no additional expense there. I also preordered a "new iPad" I won't dwell too much on that as its standard.

Next comes software, I purchased MonoTouch from the Xamarin website and then the Apple Dev Licence, all pretty basic. It is worth noting that MonoTouch does have a trial / evaluation edition, you are just limited to only having apps run in the simulator.

Total setup cost to get going: ~£868

Stage 2 - Setting up the Mac / Installing Everything

Failure to install
So the Mac arrived, its incredibly easy to setup and the packaging is very well designed. The first thing I did was to attempt to get the iOS SDK installed, this is done by installing Xcode. However I immediately hit a road block :(

I was missing a ton of updates preventing the app from installing, not cool for a new mac :(

Hours Later
So I had to then go get the software updates, annoyingly its over 1.6GB ;( This would take time on my home connection let alone my office one which is far from speedy at 2 - 3 Mb :( Eventually this finished time for Xcode...... Oh wait another 1.5Gb ;(
Warning this make take longer than 1 tea break...
Eventually after getting all of this sorted it was time to get MonoTouch installed. I have to say the installer for this was pretty painless, It does have to download and install Mono, MonoDevelop and MonoTouch but it went very quickly and was super simple to finish. In fact apart from the time it took to download everything apps on the Mac are super simple to install now theres the app store. One thing I have taken from this is I can't wait to see the Windows App Store in Windows 8, it's long over due and should hopefully make lives easier for everyone.

I then took the jump and opened up MonoDevelop, I have heard good things about it but have never used it personally.

Woohoo! MonoDevelop
And there we are. Unfortunately I was hoping to have a good play with MonoDevelop but it took over 7 hours to get all the downloads and install which ate all of my day :( There's always tomorrow .....