0

Temporal ASP.NET Bug strikes again, crazy problem crazy solution.

by Jon 15. April 2011 23:32

Just 4 months ago I posted about a weird bug with ASP.Net/IIS 6 around compiling in the UK and releasing to a different time zone.  I got hit again by it again, after a customer release we discovered parts of the system werent working correctly, several controls weren’t styling or working correctly.  It took almost an hour of diagnostics to remind myself of my original blog post, so I defiantly need to write a second post on the subject.

The problem is caused when you deploy to a timezone that’s behind you, i.e. you live in the UK and you are deploying to the USA, and it only effects iis6/server 2003 or below. When you have assemblies that return content from a webresource.xsd it will throw an exception when the dll timestamp is in the future.

You have a couple of ways to fix this:

  • Don’t use old Servers/IIS6, can be tricky if you are maintaining older code, or restricted by server choice.
  • Make sure you leave enough hours between compiling and deployment to make up for the time difference
  • Make sure your server time/computer time is set at –12 timezone time
  • After you deploy to a customer site, re-timestamp the dlls

The only sensible Option

So it appears the only sensible option is to re-timestamp the DLLs, you could do this on your CI server so this never happens (but telling your CI to compile and timestamp the dlls in the future may be tricky), or you could do it on the customer site after deployment when you hit the problem.  The command to touch/re-timestamp dlls can be done from the command line.  It involves copying the dlls over the top of themselves, and applying the correct timestamp when you do it.  The command to do this is almost more crazy than the problem:

copy /b *.dll +,,

 

yeah…. you need the + and the two ,, for it to work, crazy problem, crazy solution

Tags:

asp.net | Deploy | development

1

DDD9 Community Developer Day at Microsoft Reading

by Jon 29. January 2011 19:24

Travelling home after another fantastic DDD; an annual UK development community held at Microsoft Reading.  A big thanks must go to all the organisers and speakers that have yet again made this a fantastic day. 

Some of the topics were a bit techy so I am using this blog to attempt solidify the notes I made.  If you see any mistakes or oversights please please please get back to me so I can rectify them. 

I managed to cover Liam's talk and the basics of the other talks, I had planned to do more but I have been ill this week.  I may try to fill it out with more details if I time this weekend, or if someone gets back to me with a suggestion.

Go Asynchronous With C# 5.0 - Liam Westley

Liam went through one of the headline new features that is coming in C# 5.0 (also in vb.net 5.0), which was announced at PDC 2010 last year.  The New async keyword and its sister keyword await, are two new keywords in the language that simplify the way we perform asynchronous operations. In this world of multi-core processors and responsive handheld devices we need to be able to do several things at the same time more efficiently without making an accidental mistake that brings your code crashing down.  Liam demonstrated the problem we face by offering three members of the audience hot drinks.  If you want to do three things at the same time, (make three hot drinks), there is a temptation for a developer to start up three threads, the analogy Liam made was this is like getting three kettles out and making three hot drinks at the same time.  Its not sensible, it uses too many resources and it will take you longer!  Its better to do it in a more controlled way, but in c# 4.0 (and other languages) the extra code needed to achieve this will add extra lines to your code that muddies the water hiding the detail of what we want to achieve.

Async and Await are two words that we will use to manage the complexity better, enable use to boil hot water and make drinks quicker without hiding the complexity involved in asking people what drinks they want.  The process of making three hot drinks is pretty simple so if we can describe it in a simple way but include markers to say how we are going to achieve this asynchronously we are onto a winner. 

The two new keywords means we are able to write asynchronous code but it looks like single threaded code in your source file.  By placing the Async and Await Keywords in the right places the dotnet compiler will take your essentially single threaded code and construct call backs in the right places at compilation!

Async – We use this keyword to mark a method, its a statement of intent to say we may be performing asynchronous operation.

Await – Await can only be used within a method that has already been marked with an Async keyword.  If you place the word Async before you call a method you want to be run asynchronously the compiler will ensure the code that is after the keyword will be executed on a Callback without you having to write any extra code.

The code looks amazing but there appear to be a couple of gotchas:

  • You have to be really careful not to use the word await in your method names, you need to check your naming conventions before you implement.
  • A method marked with the async keyword can only return void, task or Task<TResult>
  • The naming convention seems a little off, as await doesn’t wait.  It is a request to continue running on a callback
  • Exception handling looks a bit funky less than clear in some scenarios which could get confusing.

It looks fantastic, and I look forwards to using it but it almost needs a health warning because it so much easier to write asynchronous code, i can see that lots of people may start using the keywords everywhere. When they start getting weird exceptions they can’t fix there will be the temptation to swallow them.  Obviously this can happen today in our current callback centric world, but there is a smallish barrier to entry.  I’m looking forwards to seeing this in the framework, if the names will stick, and what if anything will change with the exceptions.  If you want to look at this now you can grab the CTP here, but be warned its not compatible with MVC3 or VS2010 SP1.  Liam mentioned that as this is a CTP we as developers have a chance to get back to MS to ask for features or changes we want to see in c# 5.

Monads! What are they and why should I care? - Mike Hadlow

Mike Hadlow is one clever bloke, I got to the end of the talk and I wasn’t even sure if the questions I had were valid.  I thought I knew what monads were by the end of the talk but looking at my notes its still not clear.  In summary most developers probably shouldn’t care unless they are really interested in it.  From what I understand monards are used all over the dotnet framework, LINQ, IEnumerable<T> by understanding the concept you will better understand what is going on under the seams.  I need to see this again, and probably again and do some sample coding to get my head round it before I can put together a sensible overview.

But it does beg a bigger question, does the average developer need to know what a monad is?  A developers job is to create software that solves a problem quickly and cheaply, it doesn’t really matter how this is done.  It goes back to my previous post on what is Lean.  The customer couldn’t care less if you know about monads, they don’t even want a piece of software, they just want there life to be easier/nicer.  If knowing monads helps developers achieve this; great.  Its one for my list of things to read about.

Functional Alchemy: Tricks to keep your C# DRY - Mark Rendle

DRY stands for Do Not Repeat yourself.  As a developer if you find yourself writing the same code, or even doing the same thing over and over again your doing something wrong.  Mark Rendle showed us some ways we can use Functional Tricks to reduce the amount of code we write and reduce repetition.  Mark made a great point that using an OO language is can be like using a Hammer to crack a nut, not everything is an object.  Mark then went through some code, I especially liked the functional catch and the cached dictionary looked useful, although the lock looked a little dangerous for my liking.

Again in my mind software development is getting something done as quickly and as simply as possible, not having to write the same line of code over and over again is an advantage, and I loved the extra readability some of the sample code added.

Is your code S.O.L.I.D ? - Nathan Gloyn

Nathan about to start his talkKind of, but it could be alot better.  I loved this talk, Nathan took a pretty dodgy asp.net project which had inline SQL and transformed it into a thing of beauty.  He showed how you can take any dotnet code and make it much better using SOLID principles.

SOLID is a set of principles about class design, they are principles to consider not rules to apply.  Each letter of SOLID stands for a different concept which is designed to remove the nasty ‘Design Smells’ that infect code bases.

Nasty Code Smells Nice SOLID Principle
  • Rigidity – Cant Change
    Fragility – one change will break other things
  • Viscosity – changes are too much work, and a dirty hack is preferable
  • Complexity – Makes it difficult to change in future
  • Repetition – Waste of time writing the same thing over and over again
  • No Opacity – lines are code are confusing, do different things
  • Single Responsibility – Each object has a single responsibility
  • Open/Closed – Software is open for extension closed for modification
  • Liskov substitution – objects can be swapped out for different reasons, ie testing, for different database back ends etc etc.
  • Interface Segregation – Lots of client interfaces are better rather than a single fat interface
  • Dependancy Inversion – Dependencies are turned on there head so objects are loosely coupled


After whistling through the concepts Nathan then dived into code taking a legacy application and applying each of the SOLID principles in turn to refactor the solution into a much cleaner, more testable manageable project.  Nathan covered alot in this presentation and I was glad I took notes so I could look into it further when I got home.  I’m looking forwards to going to the next talk that Nathan gives.

Enforcing Code ‘Beauty’ With StyleCop - Guy Smith-Ferrier

Unfortunately I made it to this session a little late, because I had got myself into a table tennis match on xbox kinect!  Unfortunately as soon as I made it to the session I found that StyleCop is of no use to our business because it doesn’t support vb.net.  A bit of a surprise as StyleCop is open source, might take a peek if I ever get any time!

Beginners Guide To Continuous Integration - Paul Stack

I have recently implemented TeamCity in our organisation, CI is life changing.  It fits in with the DRY principle, developers should be aiming to automate any repetitive tasks and for many organisations software Builds, Testing and Release take an inordinate length of time.  Paul covered the basics of what CI is, how you should pick a CI and did a quick demo, a nice taster session for anyone who hasn't thought about CI.  It didn’t cover anything really new for me but it was nice to see a different perspective., and I liked the presentation style.  I was set next to a guy who got really interested and ended up giving him a link to my blog so he could take look at my beginning TeamCity blog series.  I think this session interested alot of people; who just want to save time and .’. save money.  The advantages to CI are clear, reduced risk, reduced bugs better testing, faster release, you can take it to another level it has even been joked on twitter that ideally your CI system should order you a pizza if you break a build Smile with tongue out

Tags:

conference | ddd | development

0

Deploying Asp.Net to a different time zone, Temporal Future Shock! Specified argument was out of the range of valid values. Parameter name: utcDate

by Jon 17. December 2010 09:57

You would have never of thought it but if you compile ASP.NET in a different timezone you could cause yourself some temporal problems.  I recently discovered that parts of ASP.NET are date specific and if you compile an ASP.NET application in one timezone (The UK), and deploy to another timezone (California) you may find that your web application won’t work correctly until the time catches up.  Its all to do with the date stamp in the assemblies, when you install your application onto a server in california the timestamps on the assembly files may be in the future and parts of the ASP.NET framework will refuse to load them.  Just by waiting 8 hours for time to catch up the problem will resolve itself!  Its defiantly worth saying this doesn’t effect all server setups I had no problems with a customer running server 2008 in a different timezone, I only came across this problem with an AJAX enabled system when a customer was running server 2003, but I haven’t had time to test different scenarios

I installed the application the AJAX was ‘working’ however nothing was styling correctly

I viewed the source of the page and started debugging by copying the WebResource.xsd url into different tab, I was surprised to see the following error:

Server Error in '/' Application.

Specified argument was out of the range of valid values.
Parameter name: utcDate

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: utcDate
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

I returned to the system after 8 hours and the site was working and the error was gone! Be careful out there, this was a fully patched server 2003!

Tags: , , , , , , ,

asp.net | Deploy | development | General | IIS | Maintanance | TechSupport | vs2010

1

What is Lean?

by Jon 11. December 2010 13:08

Its a simple question, but as a software developers what do we think lean is and are we actually right?  I was asked this very question yesterday by a Lean Manufacturing Expert and I got it wrong!  As software developers we love to dive into detail and explain and extend a philosophy much more than we should.  If you look at the origins of lean it means just one thing and it pretty simple.

Eliminate Waste

If someone asks you what lean actually is remember it is one thing! Everything else you have read  and learnt about lean is just there to support this one principle; the elimination of waste.  Its Lean and simple, don’t make it more complicated than it needs to be!  Good luck in your quest to eliminate waste for yourself, in your business/day job and your customers.

Tags:

development | General

0

TeamCity via IIS on port 80, using a reverse proxy, Part 2 host filtering so you can access Teamcity and other sites in IIS at the same time

by Jon 30. October 2010 23:29

If you followed my previous post how to setup ARR Routing to set up a reverse Proxy top access TeamCity over IIS 7.5 it will work perfectly and you will be able to access TeamCity on a different port.  However…. if you create a website under IIS on the same server you wont be able to access it because the reverse proxy is forwarding every site to TeamCity!  This might work for you but its not ideal if you want to run other IIS sites on the same server, the following steps will take you through setting up a condition so only url you specify will take you to TeamCity.

  1. Open up the Server Farm you just Created, and double click on Routing Rules
  2. Click on Url Rewrite
  3. Select the first Inbound Route and Press Edit
  4. Press the Add.. Button in the conditions pane
  5. Type {HTTP_HOST} into the condition input
  6. Ender the domain you want to want to forward into the pattern, all other domains will be passed to IIS normally
  7. Press Ok
  8. Press Apply and your done

Click on Routing RulesClick on Url Rewrite

Edit the Existing RuleSpecify the Host you want to Filter By

Tags: , , ,

Continuous Integration | development | IIS | TeamCity.Net

Powered by BlogEngine.NET 2.0.0.36
Original Design by Laptop Geek, Adapted by onesoft, and finally some tiny tweaks by JonAlb