Friday, 22 June 2012

NuGet references in solutions

If a project is shared between two solutions, and that project uses NuGet, then you have to ensure that the NuGet.targets file is added to both solutions or the project will fail to load in the solution that does not have it.

To solve the problem on the failed solution, right click the solution and select "Enable NuGet Package Restore". This will create the .nuget folder and the NuGet.targets file.

ICE errors with WIX on Win 7 x64

If you build a WIX project in VS.NET2010 on Windows 7 x64, you can get assorted ICE errors and 'failed to delete temporary directory' errors.

The solution is to run VS.NET as administrator.

Wednesday, 6 June 2012

WCF Data Services - non-unique DataServiceKey attribute causes strange results

I had a data service that was returning an IQueryable of a custom type:

public IQueryable<VolumeEntry> GetTradeVolumes(int tranNum)

public class VolumeEntry
    public DateTime StartTimeUtc { getset; }
    public DateTime EndTimeUtc { getset; }
    public int VolumeType { getset; }
    public double Quantity { getset; }

The server was sending the data in the correct form however the client was returning the wrong results. It returned the correct number of results but the VolumeType and Quantity fields were wrong - they always contained the same values.

The problem was that the custom type was actually keyed on StartTimeUtc AND VolumeType, not just StartTimeUtc as was marked with the DataServiceKey attribute.

Once modified the client returned the right results.

public class VolumeEntry
    public DateTime StartTimeUtc { get; set; }
    public DateTime EndTimeUtc { get; set; }
    public int VolumeType { get; set; }
    public double Quantity { get; set; }

Friday, 1 June 2012

''.OnContextCreated()' is abstract but it is contained in non-abstract class ''

You get this error if you create a WCF data service, but do not expose any IQueryable<T> or IEnumerable<T>. See here.