July 2009
Back from glasto.. after getting tired/wet/sunburnt all at once I've made a list of ten... exciting huh...
- I can stop myself mid-sneeze with only an odd squeeky noise emanating out instead
- I don't enjoy beard rubbing as a salutation
- I should definitely stick to seeing bands I want to see, rather than bands I think I 'should' see
- If I leave anything around the campsite I should expect it to be taken from me - but probably not too far from me
- Extended time away from computers is definitely a good thing
- If you eat too much junk food from the same vendor he will begin to learn your 'usual'
- If a guy standing next to you dancing manically asks for a sip of your drink - it may not be to help a paracetamol go down
- Feeling bad for someone can make you sit through something you really probably shouldn't
- Leaving a gap in the middle of your tents, but not putting a gazebo in it will ultimately lead to someone else putting their tents in it
- Wearing wellies in the sun, although stylish, is actually painful
Pick of the weekend? dan le sac Vs Scroobius Pip. So glad I finally got to see them.
Craig
MVC is finally installed on my home PC!
June 2009
For those intrigued by my twitter activity tonight (OK, it was just Dave and I've already told him anyway), but still, I ambiguously cried out:
OMFG really was it that simple? I hate everything right now
http://twitter.com/cargowire/status/2034102008
As a .NET developer who likes to complain about webforms I was pretty keen to get to grips with the
MVC framework when it was available. So, so I could play about with it at leisure I began a two step process:
-
Step 1: Install on work laptop - Done in seconds
-
Step 2: Install on home PC - Massive Fail
Thus began a process of occasionally coming back to it, searching for a solution, failing to find it then giving up again for a bit.
The majority of sources refer to uninstalling VS addins,
ensuring you have 3.5 SP1, ensuring you uninstall any betas etc. I tried these things and failed... Eventually it was this post by
Phil Haack that was the spur that
led me to the solution. As you'll see I even got to the point of commenting on the poor mans blog.
Several posts, including a response to another request I'd made on
the asp.net forums, were even suggesting I reinstall everything, including windows, and
start from scratch. Now I really didn't want to do that, and to be honest, thought that should never be necessary to get something to install (imagine having to
do that for every installation you undertake on your system).
Having attempted some of the ngen related activities proposed by Phil Haack without success I dug a little deeper into the log I was getting:
ExecNetFx: Error compiling System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089: Could not find or load a type. (Exception from HRESULT: 0x80131522)
Now without really having any prior experience with these kind of problems I was perhaps naively believing that the MVC install would have catered for
dependencies and that if I was getting this error clearly there was some kind of conflict or problem (the whole uninstall-reinstall stuff scenario). This was reinforced by my attempts
to run ngen ExecuteQueuedItems and ngen Update (and even an ngen delete at one point) all failing. However tonight I seemingly lucked upon the
answer.
Having already previously identified I had the System.Data.Entity library sitting in the GAC (C:\Windows\Assembly) and the dll itself in
C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Entity.dll I was still looking for some other kind of problem. However I tried, virtually on the off chance, to directly
ngen the dll myself rather than rely on the MVC installer to do everything for me.
C:\Windows\Framework\v2.0.50727\ngen install "C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Entity.dll"
Immediately after doing this I started an MVC install - it worked.
And so retrospectively I was annoyed as the action I took in relation to the error I was seeing seems pretty obvious!
Anyway it's all over, I'm off to reinstall my addins. The nice thing about it though was I ended up getting a response from an asp.net team member on forums.asp.net, which reminded me how much
I like the openness of Microsofts team i.e. bloggers, forum posters etc.
To save the jump heres some interesting info from Jacques:
In the Beta we only added support to the installer to GAC the assemblies, but starting with the RCs we began to create native images as well.
When the MVC installer runs it automatically performs an ngen update and compiles any assembly that might be deemed to be out of date. Any failure
during the ngen process is reported back and the installation will initiate a rollback.
Jacques Eloff
Further Reading for the Interested Reader
-
Global Assembly Cache - Shared store for libraries
-
Ngen.exe - Generates native processor specific machine code to avoid JITing the original assembly
Craig
New article posted! (don't hate me for my .net)
May 2009
Yesterday I Posted a new article covering some of my thoughts on .NET (check it out over in the articles section). It's in response to the many conversations I
seem to have with people who are on the verge of being shocked and appalled that I use .NET. So I decided to get some of
that discussion down on paper. It's not an intro to .NET or a comparison between .NET and the rest although aspects of both
can be found in my rambling, and I certainly don't think everyone views .NET in that way.
Craig
You really should know and use these... seriously...
April 2009
Simple things apparently annoy me a great deal...
.NET Developers should be aware of, and use, .NET constructs that have been around for ages:
-
String.Empty - avoid creation of empty string references ("") use this built in single reference and the String.IsNullOrEmpty() method too.. the framework is there to help you!
-
String.Format - avoid concatenation using + or &. Use string.format with the objects you intend to concatenate, it will also do the ToString for you and has formatting abilities.
-
StringBuilder - strings are immutable. String builders avoid the creation of new strings each time you do a & or + concatenation.
-
Using - Wrapping IDisposable instances in Using statements will automatically call dispose immediately on End Using. Additionally, implement IDisposable on heavy classes so that your own code can be consumed this way.
-
Try Catch Finally - No catch should be empty, either decorate the exception with an appropriate wrapper before throwing again or remedy whatever the problem was because just plain eating exceptions makes debugging particularly crappy. Also use Finally to ensure that even when exceptions are thrown references are disposed of appropriately.
-
'As' (TryCast in VB) - Should be used where appropriate to cast and return null if the cast fails (rather than throw a cast exception).
-
TryParse - Should be used instead of Try Catch blocks i.e. Integer.TryParse will return false if the parse failed, rather than throwing an exception.
-
Nullable Types should be used for primitive types that can also be null i.e. int? or Nullable(Of Integer). This struct has a 'hasValue' property that can be accessed rather than building your own constructs such as -1 means no value, or 0 means no value etc.
-
Generics - Do not use classes such as ArrayList or SortedList as they are object based and have the overhead of casting to and from object as well as forcing the user to do these casts. Compile time checking is also hindered. Instead use Generic Collections so that typing can be enforced i.e. Generic.SortedList<int, MyClass> or Generic.SortedList(Of Integer, MyClass).
Additionally look to use generics to create generalised code (avoid similar operations being redone in multiple specialised classes). Generics is not just applicable to classes. You can, and should if necessary, create Generic Methods e.g. ConfigurationSettings.GetValue<int>("keyName") allows casting and other checking to be encapsulated away from consuming code.
Obviously it's up to you in the context of each situation you encounter, but to never use these at all is surely madness.
Craig
Web Developer Day '09 [notes to be completed]
April 2009
The second ever Web DD is over and I'm finally home after a nice early start and lengthy drive.
However once again it proved to be a worthwhile event with interesting as well as exciting presentations. Old school
talk breakdown coming up (These are preliminary, i'll add to it when I get a chance):
| Web Developer Day '09: Speaker / Thoughts |
|
|
| Dan Maharry |
Lightweight Test Framework
Some recapping over
It would be very easy to remember the period between the release of ASP.NET 3.5 and 4.0 as the time
when ASP.NET MVC was made. But it's worth remembering that ASP.NET 3.5 service pack 1 and several
out of band releases for ASP.NET and IIS came out as well. This presentation will cover as many of
the other additions to web development as can be fit into an hour.
|
| ASP.NET 3.5 - Miss Something? |
| Alex Mackey |
Parallelisation
Oslo
We will take a look at some of the great new features available in Visual Studio 2010
and .net 4. I am currently writing "Beginning .NET 4.0 with supporting technologies"
for Apress and will share my discoveries and thoughts so far. The contents of this session
will be partly dependent on what Microsoft release in the coming months but will probably
include the more finished areas such as Azure, Language enhancements and Parallel programming.
|
| What's good in .NET 4 and Visual Studio 2010 |
| Barry Dorrans |
- Cross Site Scripting
- Injection Flaws
- Malicious File Execution
- Insecure Direct Object Reference
- Cross Site Request Forgery
- Information Leakage
- Broken Authentication / Session Management
- Insecure Cryptographic Storage
- Insecure Communications
- Failure to restrict URL access
|
| P0wn3d! (Or how to redirect your friend's website to katyperry.com) |
| Phil Pursglove |
- OutPut cache declarations
- HttpRuntime.Cache
- Compressing ViewState / storing viewstate in the session
- Using ScriptManager to compress js files into single downloads
|
| This one goes up to 11, or how to write scalable ASP.NET |
| Sebastian Lambla |
MVC Rocks
|
| ASP.net MVC best practices |
| Mike Ormond |
Mmmm control over Client Ids, Cache using a Provider Model, some good stuff here
In this session we take a wander through the landscape of ASP.NET, pausing briefly to admire what has been, before
gazing longingly over the horizon and into the future of ASP.NET 4.0. As well as enhancements to Visual Studio and
the design and development experience, we can expect to enjoy improvements in the core platform targeted at scale
and performance, significantly more control over WebForms apps, simplification and extensions of data controls and
significant new innovations in ASP.NET AJAX. I might even squeeze in a mention of ASP.NET MVC and Dynamic Data as well
|
| ASP.NET 4.0 |
Hope to meet some new people there next time!
Craig
next