CI 2

End result?

For a small team, using the service provided by the likes of Github or Bitbucket provide ample issue reporting and project wiki features with much less support required.

I guess you could outsource the actual continuous build to to Travis, but that does seem to be worth keeping in house. Too many custom features required for that to work apart from anything else.

Posted in Uncategorized | Tagged | Leave a comment

CI

Well, time to get things done. I’ve a product to build and I need a sensible environment to build it in. I’m going to run some VMs on my Mac Pro for the less exciting parts of the environment.

So far I have a linux VM that hosts Jira, Confluence and Stash. I’m building a Windows Server 2012 with Bamboo and the tools to build .Net projects. I’ll build another to use as the test deployment target.

I’ll post anything interesting that comes up.

Posted in Uncategorized | Leave a comment

The remote certificate is invalid according to the validation procedure wcf

Sometimes the Microsoft tools are too clever for their own good.

We have a WCF service which we wanted to move to SSL. The problem was: having changed the WCF security configuration to Transport, and obtaining and configuring a certificate on the server, all we could get in a response was the above exception. Even using the visual studio WCF Test Tool.

The solution was revealed by looking at the configuration files that were created.

For the WSDL we had entered a URL like ‘service.intranetdomain’, the URL on the certificate.

The generated client config replaced ‘service’ with the raw hostname of the machine, which of course did not match the certificate.

Edit the client file to correct the change – everything works 🙂

Posted in WCF | Tagged , | Leave a comment

Duplicate Key Exception

Entity Framework throws exceptions from the DbContext’s SaveChanges method if there is a constraint violation in the database. If you have a property marked as invariant w.r.t. concurrency, that too will raise an exception at this point (a

DbUpdateConcurrencyException

Exception.

If you are using Sql Server, nested inside the UpdateException as an inner exception, which is nested in the DbUpdateException as an inner exception is a SqlException.

If you cast this to a

System.Data.SqlClient.SqlException

it will have a property Number that will correspond to the Sql Server Error Number

A common one to be interested in is the exceptions thrown by duplicate keys. In Sql Server there are two posssible error numbers : 2627 and 2601. Which one you get depends on the way the unique constraint was created.

An index created on a table created with the unique clause would result in a 2601. Adding a unique constraint will result in a 2627 in case of a duplicate key insertion.

                
catch (DbUpdateConcurrencyException ex)
{
    new ConcurrencyException();
}
catch (DbUpdateException ex)
{
    if( null == ex.InnerException || ex.InnerException.InnerException) throw;

    var innerException = ex.InnerException.InnerException 
                           as System.Data.SqlClient.SqlException;
    if (innerException != null && 
           (
               innerException.Number == 2627 || 
               innerException.Number == 2601)
           )  
      {
          throw new AlreadyInsertedException();
      }
      else
      {
          throw;
      }
}
Posted in EF | Tagged , , , | Leave a comment

Glimpse

That turned out to be a profitable search. A bug that suggested that there was a routing configuration issue in a .Net MVC app. I was looking for a way to troubleshoot the issue and I came across this: Glimpse

It really does provide wonderful instrumentation of many aspects of an Asp.Net application. I will try and provide some examples. For now just go to their site and have a look. Also have a look here.

Oh yes – it is available as a Nuget Package…

Posted in C# | Tagged , , , | Leave a comment

SignalR

Wow.

I just looked at Signalr again…

Just added the Git package to a web application, added the git package for the stock ticker example, fixed the bug on the stockticker html page that referenced the wrong version of the sample .js and ran it.

Ok, a stock ticker with values pushed from the server. Nice.

Then I looked for the “service configuration” at the server end. You know: all that XML you get wrong setting up a WCF service?

None. Nope, not a bit.

The client is HTML + Javascript and none there either!

And you can use it for calling services as well as streaming data to the client.

So again: WOW!

And you look at the code and go: that looks easy, and then knock up an example yourself just to make sure (Silverlight client this time). And yes, it really is that simple.

 

I’ll do some more detailed posts after I calm down 🙂

Posted in C# | Tagged , , , | Leave a comment

Silverlight HyperlinkButton Background Colour

Oh dear – I think I over thought this one. To cut a long story short, a client app I was maintaining had a top level menu composed of HyperlinkButtons. The requested change would involve a proliferation of these controls.

Solution was to move the controls into sets in separate TabItems in a tab control.

Problem was that the control for the current HyperlinkButton was no longer highlighted. I spent a long time looking at the custom style they had trying to get the required effect back.

Two coffees later it occurred to me to have a look and see if there was any forbidden magic in the code behind. (The rest of the app was strongly MVVM). and yes there it was – the OnNavigated handler iterated through the hyperlink buttons in the original container and used the VisualStateManager to set their state to ActiveLink if the url matched and InactiveLink if not. Doh!

 

Posted in C# | Tagged , , | Leave a comment

Architecture : Entity Framework

I’ve had an extensive opportunity to play with entity framework. Here are my few thoughts.

Code first does work reasonably well if you are starting from scratch, but managing the release of vital enterprise applications, which require care around the DB become harder after the first few iterations. So far it has been easier to retrospectively create an .edmx from the code first created database, edit it to fit the existing object model and continue from there. It helps to decouple the database changes from the code.

To be honest, in future I would be tempted to build the database first now that the tools in Visual Studio are so much better and generate a first cut at the model, kill the generation and use the generated files as a starter for 10.

Any thoughts?

Posted in EF | Tagged , , | Leave a comment

Architecture : Implementing IOC

I’m guessing this is obvious to most of you, but it would be good to get some comments. Most IOC examples I have seen tend to be kind of trivial, it’s easy to expose the required dependent as a property or a constructor argument. I’m wondering about the implementation in cases where: The object needs access to a factory for the objects as it is long lived and requires to create them on an ongoing basis, objects that require several dependents and deep trees where each level has options on implementation.

It’s the sort of problem you can approach using a locator easily enough e.g. Unity.

I’m not too keen on that approach because I prefer my dependencies and configuration to be spelled out.

Given that we ca be dealing with a tree means that constructing from the lowest level up isn’t too clear either, especially if there are factories involved.

My approach at the moment is to craft a structure with named methods for all the dependents in a tree. If there is a requirement to build objects on the fly, then the property for that situation is of type Func<…IOUT> where there are the required number of parameters. There is a top level object with properties for all the trees.

For me, this seems to provide the minimum of coding, yields ease of testing, makes all dependencies explicit and allows specific implementations in a deployment easy to find.

Posted in Uncategorized | Leave a comment

Moving Entity Diagrams in Entity Framework

I had a project with a .EDMX in it. I had matching classes and stuff in another project that had started out as a code first development. I copied the .EDMX to the new project and lo there was the error Metadata not found…
Important thing to know: if you copy the .EDMX into a sub-directory, the sub-directory name extends the name of the model file in the connection string.
so a file called Model.edmx in a sub-directory Repository should look like this in the connection string: res://*/Repository.Model.csdl|res://*/Repository.Model.ssdl|res://*/Repository.Model.msl

Posted in Uncategorized | Leave a comment