Archive for 2010

:   :   :  

Displaying Assembly Version in Windows Explorer

Posted on 26 November 2010 1 comments

fileversionI have been working a lot with upgrading assemblies to newer versions and debugging why things does not work. When doing this you often have to check which version you currently have in your “bin” folder. This takes quite a lot of time as you have to check properties of each file (or hover of the file and wait for the tooltip) to see the assembly version. It is hard to get a quick glance over all your dll versions.

What I did was to add a new column to Windows Explorer which shows the file version. Follow the steps below to show file version in Windows 7:

  1. In the bin folder, right click on the column row and select “More…”.
  2. Search for and mark the item called “File version” and click OK.
  3. You should now see a column with the version number!

Read More »

Notes from Øredev 2010

Posted on 16 November 2010 and tagged with , 1 comments

Time flies – the Øredev week is already over and I’m back at the office. The conference was really great. Reaching above my expectations. It was of course great to learn a lot of new stuff, but what I think was the best part about the conference is that it gives you a lot of inspiration to create applications, try out new things and walk that extra mile to make your application more maintainable and tested.

The sessions were divided in different areas, e.g. .NET, web development, agile and smart phones. It was never hard to find a session I wanted to go to. I, however, recommend to create your own schedule beforehand as it’s really handy to have with you when you’re at the conference running between sessions.

During the sessions I tried to write notes about the things I found most interesting, but it was hard to keep up with both listening and taking notes. Following is notes I wrote down from some of the sessions I attended.

Patterns for Building Internal DSL's in C# 3.0

In this session Jeremy D. Miller talked about Fluent Interfaces which are handy in certain APIs, like a Twitter client API.

When creating such interfaces you should think about:

  • Don’t try to make everything grammatically correct. Small and tidy method names are better and easier to understand.
  • You should limit the possible choices in the API to guide user to the right methods. This can be done by using Interfaces instead of returning the same object over and over again.
  • You should keep the chaining within 3 chain calls.

Better Practices for Building Fast Web Apps

This was quite an interesting talk as it covered lots of tools I hadn’t heard of before. Giorgio Sardo mention tools you can use to increase the performance of your sites. Like using sprites, finding out not used CSS styles and a tool called Doloto that converts your existing scripts to be lazy loaded instead.

The tip I liked especially much was when he mention about a new API called Web Timing API that browsers are starting to implement. It can be used to find lots of details about how fast your site has loaded. I knew about this API before the talk, but what caught my attention was when gave the smart tip of actually sending this data (serialized JavaScript object) to the server to get free profiling information from your users. How cool isn’t that!

//IE
window.msPerfomance

//Webkit
window.webkitPerformance


CSS3

CSS3 with Jonathan SnookJonathan Snook talked about all the new fun things in CSS3, like animations, transitions, border-radius and shadows of all kind, etc. He also went through all different browsers and what they currently support.

Until CSS3 is ready it has to go through these states: Working Draft, Last Call, Candidate Recommendation, Proposed Recommendation and finally Recommendation. Note that each module in CSS3 has its own state, and not one all together. You can see in which state each module is in at the W3C site.

Good links shared by Snook:

ASP.NET MVC 3

A few days before the conference Scott Gu (and all other the bloggers) announced that ASP.NET MVC 3 Release Candidate was released. This is great news as it means there is only bug-fixing left before we get the final version. Brad Wilson had this talk and he did it great! He talked about the new Razor syntax, the new package manager NuGet and some new features in MVC 3.

  • Partial caching in child actions.
  • Unobtrusive JavaScript validation.
  • Razor syntax highlighting in Visual Studio.
  • A way to turn of session for a controller ([ControllerSessionState()]).
  • And lots more…

“Abusing C#” and “C#'s Greatest Mistakes”

Jon Skeet abusing C#These two talks was given by Jon Skeet, the man, the myth, the legend in C#. It was a really interesting talk covering lots of different ways to hack around in C# in ways you maybe shouldn’t do in production mode.

The two talks were very similar in the way they were presented. They both had no slides and only covered Skeet going through examples of areas the audience wanted to learn more about. It really felt like we could fill a whole conference with only Jon Skeet talking about C# (I would totally go on it).


Now I’m eagerly waiting for Øredev to publish the videos of all the other sessions I didn’t attend to. It seems they will be published on Vimeo. Read more details about the other sessions at my colleague’s blog Dileno. See you at the next Øredev!

Read More »

Schedule for Øredev 2010

Posted on 8 November 2010 and tagged with , 4 comments

The yearly Øredev Developer Conference is now closing in, and I’m really excited to be able to participated this year. I’m leaving Wednesday and getting there around 10-11 AM which means I will unfortunately miss a few sessions in the morning but I’m sure the other sessions will weight up.

I look forward to learning a lot of new interesting techniques and patterns, especially in sessions covering .NET, web app development, HTML5/CSS3 and nosql. It will also be great to see people like Jon Skeet, Brad Wilson, Jeremy D. Miller and Jonathan Snook “in real life”. Makes me wonder if Jon Skeet will even answer questions now when he can’t get any up-votes for it?

The sessions I will attend to are:

Wednesday

  • 11:20: ASP.NET Web Matrix and Web Pages, Brad Wilson
  • 13:10: Patterns for Building Internal DSL's in C# 3.0, Jeremy D. Miller
  • 14:15: Better Practices for Building Fast Web Apps, Giorgio Sardo
  • 15:35: Automated Testing of Web Applications, Jeremy D. Miller
  • 16:40: CSS3, Jonathan Snook

Thursday

  • 10:15: Higher-Order JavaScript, Giles Bowkett
  • 11:20: Exploring Windows Phone Dev, Jeff Wilcox
  • 13:10: CouchDB for .NET Developers, Hadi Hariri
  • 14:15: ASP.NET MVC 3, Brad Wilson
  • 15:35: Abusing C#, Jon Skeet
  • 16:40: Compositional Design with Responsibility Driven Design, Jeremy D. Miller

Friday

  • 10:15: My last 30 failures, Ted Valentin
  • 11:20: C#'s Greatest Mistakes, Jon Skeet
  • 13:10: 19 1/2 Things to Make You a Better Object Oriented Programmer, Greg Young
  • 14:15: Top 20 tools and tips that make me a better developer, Roy Osherove
  • 15:35: Pluggable web applications, Rob Ashton

= me like.

Read More »

“Key has already been added” exception with PageTypeBuilder

Posted on 7 October 2010 and tagged with , , 3 comments

This is one of those exceptions you get and you know you have had them before but never remember the solution, and googling them doesn’t give you any answers. Time to fix that!

Background

I was in the process of creating lots of new page-types for a new EPiServer  website and suddenly it threw an exception after building and running the site. The exception message I got was “An item with the same key has already been added.” with the following Stack Trace:

[ArgumentException: An item with the same key has already been added.]
   System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +56
   System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +10290303
   System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) +12
   PageTypeBuilder.PageTypeResolver.AddPageType(Int32 pageTypeID, Type pageTypeType) +52
   PageTypeBuilder.Synchronization.PageTypeSynchronizer.AddPageTypesToResolver(List`1 pageTypeDefinitions) +159

What we can understand from the above Stack Trace is that when PageTypeBuilder adds a new page-type to the dictionary it fails because another item with the same key already exists. My colleagues and I were determined this key must be the page-type GUID that you specify in the attribute of a page-type. I opened the database and deleted all page-types directly, and then changed the GUIDs in my classes. This has to work – but it did not.

Solution

I gave up and continued working with my page-types. After a few minutes I found a page-type with an incorrect name – it was a duplicate of another page-type! I changed it to the right name and ran my site. Everything worked! I had been affected by the “copy-paste error”.

To sum it up: Every page-type must have a unique Name property or else it’ll fail in runtime.

It would be nice if PageTypeBuilder threw a friendly exception if the key already exists. If the exception message also mention which page-type (by ID or name) it would be really easy to find and solve the problem.

Maybe it’s time to submit a patch to the PageTypeBuilder project?

Read More »

Import Namespaces for Razor Views

Posted on 28 July 2010 and tagged with , 0 comments

Previously when developing with the WebForms view engine we could use the Web.config file to import namespaces where we stored our extension methods or models. They would then be available to all our views without having to explicitly declare them in each view.

In Razor this is no longer possible due to how it’s built, which is why we have to manually register them in the Application_Start event.

To do this begin with opening Global.asax and create a new method called RegisterGlobalImports, and call it from the Application_Start method. In the newly created method you add all the namespaces you wish to have in your view by calling AddGlobalImport on CodeGeneratorSettings.

public static void RegisterGlobalImports() {
    CodeGeneratorSettings.AddGlobalImport("MvcApplicationRazor.Core.Extensions");
    CodeGeneratorSettings.AddGlobalImport("MvcApplicationRazor.Core.Models");
}

protected void Application_Start() {
    RegisterGlobalImports();
    
    AreaRegistration.RegisterAllAreas();            
    RegisterRoutes(RouteTable.Routes);
}

I usually register extension methods, that should be available in the view, and models so I won’t have to type namespaces over and over again.

Read More »

Loading Posts...