Windows Phone 7 – my personal statusupdate

by DotNetNerd 19. September 2010 16:49

This past week I went to a meeting at Trifork about Windows Phone 7, with very big expectations. As an enthusiastic .NET developer the prospect of Microsoft “getting in to the game” of phone development is incredibly interesting. My thoughts before the meeting was that I would probably be talked into buying one right off the bat, so I could get started with writing my own apps.

The meeting started out great with the presenter being all smiles, and with a lot of praise for the phone and the experience he has had playing with it and with the developer tools. He was also happy to show a little app he had written and talked about the nice experience of working with the developer tools and MVVM light. In spite of the presenter being happy about the product, quite a bit of the talk ended up revolving around limitations arund the software that you get out of the box, as well as limitations for the developer.

More...

Tips and tricks for keeping up-to-date

by DotNetNerd 1. September 2010 16:39

These days a lot of people in the software business, including myself, do (or should do) some work to keep up with technologies, and what experiences others have. This includes quite a bit of reading both on misc websites and blogs. This can at times feel like quite a bit of work, because technologies that might be relevant tends to come in bundles, and if you wish to follow the relevant blogs it may be quite a few which means new updates every day.

More...

Tags: ,

Testing Delicious Bookmark Plugin for WLW

by DotNetNerd 18. August 2010 14:43

Tags:

NU – gem like packaging for .NET

by DotNetNerd 26. July 2010 20:37

I just had a look at NU which is made to be for .NET what gems are for Ruby. Why should you care? Well if you are like me downloading new versions of miscellaneous open source projects and updating them along the way is not your favorite thing. It’s just tedious and seems to be a hassle for something so basic. This is where NU gives you a hand.

If you have IronRuby running simply open an command line and type:

igem install nu

Then when the installation is done go to the root of your projects folder (eg. D:) and type:

nu install <some_gem>

I started out running “nu install nunit” and “nu install nhibernate” and in less than a minute I had nunit, unhibernate, log4net, castle.core and castle.dynamicproxy2 unpacked to D:\lib like this.

image

Like a good handyman a developer needs his tools – and plugins

by DotNetNerd 23. July 2010 17:34

Over the last couple of weeks I have been looking at quite a few new frameworks, tools and plugins. My focus area has mainly revolved around an app that I will be building that needs to pop and therefore it will make pretty heavy use of javascript and css - and of course by extention jQuery.

First of all dotLessCss deserves a mention, even though its actually not one things I looked at now. Basically it allows you to do some of the stuff you probably miss when working with css. Variables, mixins and nesting really helpes reduce all the repetitiveness. SquishIt is a little library I read about a while ago. It makes bundeling and minimizing javascript and css files as easy as can be. On top of that it also makes sure the files get versioned, so you won't run into users running on an old cached version.

In the category nice jQuery plugins I have looked at quite a few things. jQuery cookie addin makes it a no brainer to work with cookies. Watching a video from NDC I learned that newer browsers now support other ways of saving data on the client called sessionStorage and localStorage. As always the problem is compatibility, but there is a shim to fix this for IE6 and IE7, which are the main culprits.

I also looked at a few flashy jQuery addins, and FancyBox and Cycle solve a few of the things designers crave these days while being super simple to implement. Now that we are in the design department Cufón helpes you do font replacement easily, so you can use cool non websafe fonts.

Video is an area where there are quite a few options available, and it is becomming a jungle figure out which players support which formats and run in which browsers. Video for everybody is a simple way to implement videos in a way that will work across all the popular browsers. The idea is to use the html 5 video tag and then default to others where it is not supported. If being crossbrowser is not quite that important but designing the player is Silverlight has some great optios as well as flowplayer. Both are also easy to work with from javascript almost as straight foreward as the html 5 player API.

Lastly I saw a tweet about TopShelf and decided to try it out. Safe to say, I'll probably use it everytime I need to write a Windows Service from now on. It makes it just a little easier, and allows you to run your app either in a console or as a windows service.

 tools

Tags: , ,

IronRuby 1.1 with LINQ support

by DotNetNerd 20. July 2010 08:37

Finally LINQ is supported in IronRuby now from v. 1.1 and I think it has been solved quite elegantly without any real syntactical gooeyness. Trying it out has been made very straight forward by looking at the 101 LINQ samples rewrite for IronRuby.

From day one LINQ has seemed a natural fit with IronRuby already having a similar approach with functions such as .each {|item| ...} which is accessible on anything that can be enumerated - very much like a big part of LINQ is extentions methods to the IEnumerable interface. No doubt there has been some challanges around how to map generics, extention methods etc between the languages, but syntactically it seems a natural fit.

products.where(lambda { |p| p.units_in_stock > 0 and p.unit_price > 3.00 }).each { |x| puts x.product_name }

Combining functional methods from LINQ with the existing Ruby methods just makes the "Integrated Query" syntax even better. So now we get a .each method with LINQ even though Microsoft originally didn't want to include it :)

 

Tags: ,

IronRuby and hashes in metaprogramming

by DotNetNerd 29. June 2010 19:39

This will probably be one of the shortest blogposts I'll ever write, and probably the one with the least amount of code - besides an occational rant. The reason is that like pictures sometimes say more than a 1000 words, so does elegant code.

module MyModule
class MyClass
def write_stuff text
puts text
end
end
end

m = MyModule::MyClass.new
actions = {:write_stuff => "Hello action packed world!"}
actions.each {|key, value| m.method(key).call(value) }

It might just be me who is weird - but I think this way of doing eg. a strategy pattern is pretty cool.

Tags:

Ajax-enabled WCF services and loadbalancing

by DotNetNerd 10. June 2010 20:35

This week I ran into a problem when we were deploying a webapplication that uses ajax-enabled webservices to an environment that uses loadbalancing. The services were running fine in the stage environment and when each of the servers were called directly, but as soon as we went through the loadbalancer they failed.

I started by checking if the svc files could be reached, and surely enough they could be accessed from the servers, but through the loadbalanced domain I got a 404.

Reading blogposts on the subject provided little help – well actually it just hightened my degree of confusion. So after some time I started thinking about IIS bindings. I remembered that I had written a custom WebScriptServiceHostFactory because we had several bindings which IIS doesn’t handle too well.

using System;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Activation;

namespace MySite.ScriptingService
{
    public class MyCustomHostFactory : WebScriptServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            //This makes it possible to control which binding is used by sorting them in IIS.
            return new ServiceHost(serviceType, baseAddresses[int.Parse(ConfigurationManager.AppSettings["BindingIndex"] ?? "0")]);
        }
    }
}

I started playing around with which binding we used, and as I suspected if the binding was not the one for the loadbalanced domain it returned the 404. This was one of those “doh!” moments. I still had a problem though, because the site could be accessed both with and without the www subdomain. A colleague pointed to the fact that we could use the URL rewrite plugin for IIS, and have it ensure all traffic was directed through one of the domains. As it turnes out it actually has a CanonicalHostNameRule that does just this because its a SEO good practice. Only issue I had left was that umbraco on the other hand has a practice that it must be accessed directly on one server, so changes are made on the master and replicated to the slave(s). This just required extending the conditions so it does not redirect if the umbraco folder is part of the path.

IIS routing

So now by posting this I hope Ill save someone else from getting a few extra gray hairs, and if not maybe I’ll save my self some other time when I can’t remember how I did…

Tags: , ,

Hello rake-world

by DotNetNerd 27. May 2010 16:31

Rake is a quite popular build framework, that has its strengths in the fact that it is code (no more xml), and it is very simple to get started with. Actually setting it up is a 3 step process.

  1. Make sure the path environment variable is set to point at your ironruby/bin folder.
  2. Run “igem install rake” from the commandline
  3. Write a Rakefile.rb like the following and place it at the root of your site

require 'rake'

task :default => [:say_hi]

desc "Does quite a bit of greeting"
task :say_hi_to_me do
    puts "Hello me. Now that was easy."
end

task :say_hi_to_world do
    puts "Hi world!"
end

task :say_hi => [:say_hi_to_me,:say_hi_to_world] do
    puts "I’m, all hellowed out"
end

This really all it takes, so now you are ready to run your tasks from the commandline by writing: “rake” or “rake say_hi_to_me”.

Now for this to get really interesting you will need albacore which makes it easy to do all kinds of basic tasks.

This is installed with the command “igem install albacore”, and makes it possible to do builds and run unittests like this:

require 'rake'
require 'albacore'

task :default => [:full]

task :full => [:clean,:build_release,:run_tests]

task :clean do
    FileUtils.rm_rf 'build_output'
end

msbuild :build_release do |msbuild|
  msbuild.properties :configuration => :AutomatedRelease
  msbuild.targets :Build
  msbuild.solution = "TestApp/TestApp.sln"
end

nunit :run_tests do |nunit|
    nunit.path_to_command = "tools/nunit/nunit-console.exe"
    nunit.assemblies "build_output/TestAppTests.dll"
end

rakemonkey

Tags: ,

Silverlight and IronRuby – a match made in heaven

by DotNetNerd 25. April 2010 10:31

A couple of months ago I was starting to read about IronRuby, and while thinking about what my first little pet project should be I saw a tweet from a guy who was enjoying the combination with Silverlight. I gave the idea some thought and liked the idea of using a dynamic language to make a rich internet application. So after reading IronRuby UnleashedI started out doing a version 2 of my dotnetnerd.dk site – which is just a little toy selfpromotion site.

Getting started was pretty straight forward because with IronRuby there is a small webserver called Chiron, which can make a project template. All you have to do is open a cmd, and go to the library where IronRuby is installed and type script\sl.bat ruby <projectpath>

Armed with my starter template I began playing around and got my layout in place. I also tried using some 3rd party components by referencing some dll’s and all that basic stuff. Most of it went smoothly, but I did run into an assembly (Flickr.net) that threw an exception when used with Silverlight/IronRuby. Using it from a console project in IronRuby worked fine, so I quickly decided to just go directly against the flickr api using the .NET WebClient class. Running the site from chiron was as easy as calling script\chr.bat /d:<projectpath> /b:index.html

When I had the first couple of pages ready and had written a picturegallery showing the last 5 pictures I have uploaded to flickr I wanted to get the site deployed, so I would no longer depend on chiron. From my book and by looking at blogs it seemed to be smooth sailing, because chiron has a function that makes a .xap file which is all you need. To my surprise when I referenced the .xap file from the html file in my my project it looked like it loaded, but then just stopped at 100% without showing my actual site. I felt pretty stuck, because I had no exception or anything to go on, and my site ran fine when I was using chiron.

I then wrote an email to “Iron” Shay Friendman, who wrote the book that I was using as my inspiration. I thought it was worth a shot, and that I could not be the only one with that problem. Later that day he wrote back, and (as the nice guy he is) told me that he did not know the solution off the top of his head but he would look at it as soon as he had a couple of available hours. A few days later he had found a solution, and it turnes out a few things need to be done differently when running it outside of chiron. So this is basically what I want to share with this post :)

What you need to do is:

1) If your .rb files contain references like “app.xaml” it should be changed to app\app.xaml – in other words the references should be from the root of the solution and not from the app folder where the file is located.

2) Make the .xap file using the command script\chr /d:<projectpath> /z:<projectpath>\app.xap

3) In the index.html file where the .xap file is referenced find the like starting with <param name="initParams".
Change its value attribute to "start=app\app.rb,reportErrors=errorLocation".

And easy as 1-2-3, your site should work when running the index.html file.

Shortly put it really has been a fun project, and I really like the IronRuby and Silverlight combination, so it is definately not my last project where I will combine the two.

ironrubylogo

Who am I?

My name is Christian Holm Diget, and I work as an independent consultant, in Denmark, where I write code, give advice on architecture and help with training. On the side I get to do a bit of speaking and help with miscellaneous community events.

Some of my primary focus areas are code quality, programming languages and using new technologies to provide value.

Microsoft Certified Professional Developer

Microsoft Most Valuable Professional

Month List