Archives

Archives / 2009
  • Most Wanted: IronRuby Integration in Visual Studio 2010

    ironruby This week the IronRuby team announced IronRuby version 1.0 RC at RubyConf 2009 and IR is really starting to shape up into something awesome when looking at compatibility and performance.

    The blog to really, really follow if you’re interested in IronRuby is Jimmy Schemanti’s (PM and developer on the IronRuby team). He’s got up-to-date information on the project as well as good tips on how to make best use of IR in your other .NET projects.

    In a couple of places on the Net, there’s been discussions and also deep concerns about the fact that there is no proper support for the Iron* languages inside Visual Studio. One interesting discussion is going on in the IronRuby mailing list –> http://www.mail-archive.com/ironruby-core@rubyforge.org/msg05124.html and another over at Sapphire Steel, who released an alpha version of IR integration in VS2008 –> http://www.sapphiresteel.com/Who-Needs-IronRuby 

    A couple of months ago, Matt Ward wrote a blog post about IronRuby integration in SharpDevelop 3.1. SharpDevelop being an open source IDE for the .NET platform which supports various project types and multiple programming languages. Today, this might be the best option for people who are used to the the programming support you normally get in Visual Studio.

    Personally I would hate to see the thousands of hours from the IronRuby team and the wonderful community being spent on a product not used just because the lack of VS integration. It’s my personal view that most .NET developers have been totally spoiled by the wonderful support VS gives us. We’re used to getting project support, syntax highlightning, refactoring, F5 debugging and at least *some* intellisense. 

    I know that some people over at Microsoft is a bit disappointed in the community (IronRuby is a kind of an Open Source project after all) for not doing something in VS for IronRuby already – Sapphire shows is possible for sure, and it should be even “less hard” in VS2010 – but I think I know why. Coding up a good VS integration with the features I listed above is NOT a walk in the park to get right. We’re talking thousands of hours that MIGHT go down the drain if Microsoft eventually releases something themselves.

    For a while now there’s been a suggestion on Microsoft Connect for IronRuby integration into VS2010, which has now become the most up-voted feature request for VS2010!

    A couple of days ago, Jimmy commented this on his own blog post:

    VS integration will happen eventually; we've been focusing on the languages up until now. After the 1.0 is released we'll probably have some time to make the VS integration. However, I'm a little disappointed in the community for not making this already ...

    And yesterday Jimmy wrote:

    After 1.0 is released, we’ll probably take a bit of a break, but then look to do some features we didn’t get to finish in 1.0, as well as Visual Studio Integration, since it’s the highest voted feature for VS2010.

    So, there you got it. It WILL happen eventually, I wish it will be sooner than later and I hope to see the same kind of short release cycles we’ve seen for IronRuby. :D

  • Weeko – MEF and WPF to plug in Tool Windows into Visual Studio 2010

    Today I opened up a new Codeplex project called “Weeko”, which is a Sioux name for “pretty”.

    Weeko is an experiment which uses MEF to easily plug in tool windows into VS2010. The tool windows are developed as ordinary WPF UserControls. Install the Visual Studio extension and drop your user control assembly into the extensions directory of Visual Studio and it will show up inside the IDE.

    This is how it can look with a couple of sample “addins” – The Rss feed, Twitter feed and a digital clock are all WPF User Controls which are exported and imported using MEF – Managed Extensibility Framework.

    sample.png

    Feel free to check it out and if you got some ideas for improvements please let me know. I’m thinking about how to better manage available plugins, load/unload etc.

  • Some Good Feedback for Writespace

    WritespaceIt’s been a while since I actually looked at the Codeplex statistics for Writespace, but it seems that people keep downloading it and that’s always fun! So far Writespace has been downloaded over 4.000 times which is peanuts compared to other open source tools, but perhaps I helped some people get more productive and that feels good!

    Following the top referring sites I can see that this simple addin for Word gets some good reviews from people that compares it with other similar tools. One of the best articles I’ve seen so far is the one by Rob Oakes, which he calls On Writing – Software that cuts out distraction and clutter where he compares DarkRoom, WriteRoom, Writespace and PyRoom. They are all very similar to each other.

    What’s not so cool is that Writespace is an open source project, and it would have been fun to get some patches or help from other developers. Of the 4.000 downloads, I’m sure there are a whole lot of .NET developers that know their XAML well. I’ve got some feedback for ideas, one guy I know made some changes but didn’t send me code or a patch… pity. If you extend open source software, shouldn’t you share that? Maybe it’s too hard to create a patch?

  • Writespace Updated with Command Line Version and Some IronRuby Fun

    WritespaceI had a few minutes to fix a few issues and release an updated version (1.3) of Writespace – the full screen editing environment addin for Word.

    So what’s new? I removed the annoying illuminated animation for row and column when typing. Added F4 shortcut for the Options dialog. Also added a command line program and a sample ditto to run Writespace with IronRuby.

    IronRuby can be downloaded from http://ironruby.codeplex.com 

    The command line programs are optional downloads, but it seems to run pretty well if pinned to the Windows 7 TaskBar:
    Win7Taskbar.png

    Have fun!

  • SQL Azure Explorer on Channel 9

    SQL Azure Explorer LogoOur SQL Azure Explorer Addin for VS2010, which is on Codeplex was mentioned on the  Last Week on Channel 9 show, which is cool. Made the download stats peek even though it’s for VS2010 Beta 1 only and you need to have an SQL Azure CTP account. 

    That show is one of the best for people like me who need to keep up with the latest stuff happening on the Windows and .NET front.

    I need to get some time and refactor the data access layer. It works, but it’s not consistent and could use more integration tests. Or I’ll let it be and just work on new features, which is way funnier ;)

  • Custom Caret “cheat” in WPF TextBox

    I’ve seen people ask for custom Carets in the WPF TextBox, like in insert mode and you want to have a block caret or underscore. Some say it’s going to be possible/easier to do this in .NET 4.0, but until then, there are some simple cheats you can do to add it yourself, but it will need some tweaking. In this test I’ve put a Canvas on top of the TextBox, on which I draw the custom caret and move it when keys are pressed in the TextBox. If you absolutely need this behavior you can probably tweak it to work, but movement, drawing and all that depends on the font face and size.

    CustomCaret

    In my sample code, the custom caret is invisible to start with, and only drawn when in overwrite mode. The drawing is kind of jerky when using the arrow keys and home, end etc, but I think it can be fixed. One way would be to make the built in caret the same color as the TextBox background, like described by Lester in his blog post.

  • SQL Azure Explorer Addin for VS2010 Beta 1

    Me and Dag König just released the alpha version of a (so far) small Codeplex project we’ve been working on for the last week or so – an SQL Azure Explorer Addin for Visual Studio 2010 Beta 1.

    The reasons for this project are several, but mostly to learn more about VS2010, how to create addins for it, dig into SQL Azure and at the same time learn some WPF and XAML.

    The addin is a VSIX package and easily installed in VS2010 by just downloading and double clicking it.

    Here’s a sample screenshot of the explorer and the integrated SQL Editor:

    SQL Azure Explorer Addin

    If you got VS2010 Beta 1 and some SQL Azure databases you work with, please download and feedback. I’m sure Microsoft will eventually support SQL Azure in the built-in server explorer, but as I said, this is for fun (it’s great fun to code addins) and the code might be useful for other future projects :)

  • Visual Studio 2008 Web Test Not Recording on 64-bit Windows 7

    vs I was about to record a web test in Visual Studio 2008 Team System today, and the recorder refused to record anything. And the Recorder “bar” in IE 8 was not showing. After some digging around, the issue was fixed by deleting a few registry keys. Found it on Michael Taute's Blog : Diagnosing and fixing Web Test recorder bar issues.

    Quote from his blog page:

    Vista caches the list of explorer bars you have available and the recorder bar was not included in your list. The fix is to force Windows to rebuild that cache. To do this, first make sure you have all Internet Explorer instances shut down, then open the 32 bit registry editor and delete the following keys:


    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories\{00021493-0000-0000-C000-000000000046}
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories\{00021494-0000-0000-C000-000000000046}

    [Note: by default, the 32 bit registry editor is located in %WINDIR%\SysWow64\RegEdt32.exe]

    The next time you boot Internet Explorer, your explorer bar cache will be rebuilt and the recorder bar should be available.

  • Windows 7 RC Feels Very Stable

    Windows 7 I upgraded to Win7rc as fast as I could from the beta and pretty much all the problems I had on the beta are gone! I’ve never experienced a beta OS as stable as this one, it’s nothing short of impressive.

    Hangs on reboot/shutdown are gone.

    Annoying stuttering sound probs are gone.

    File copy probs are gone.

    Screen update probs gone.

    I’m running 64-bit on a DELL Precision M4400 and the funny thing is that think I’ve not installed any extra drivers except for the touchpad and the initial network drivers, and it runs like a charm. It was a nightmare to get it working properly on 64-bit Vista, even when it came pre-installed with it from DELL! (Shame on you DELL to ship a box that doesn’t even run properly on the pre-installed software!!)

    I will have to install the extra software to get the built-in 3G mobile network running and that was kind of tricky on the beta, and the finger-print reader I’m not even going to bother with.

  • Windows 7 Release Candidate Availability

    Windows 7 BetaGlad to read about the upcoming RC release of Windows 7. Just wondering how I should “migrate” to the RC from by current beta as I’ve spent days and days to get it in pretty good shape. Lots of job, but Win7 is just worth it.

    From the Askperf webby:

    We now have some dates that we can share with you.  The RC build is slated to be available for download by MSDN / TechNet subscribers this Thursday (April 30, 2009).  Broader, public availability will begin the following Tuesday (May 5, 2009).  If you haven’t already started using Windows 7, there are plenty of changes since the Beta release.  You can read more about these changes in the following posts from the Engineering Windows 7 blog: Some Changes Since Beta for the RC and A few more changes from Beta to RC…

  • Restored 64-bit Windows 7 Beta from Windows Home Server Backup on a DELL Laptop

    Windows 7 BetaThe HD of the new DELL Precision M4400 I have crashed, burned and died yesterday. I heard the screams 3 rooms away while drinking my morning coffee. It was horrific.

    Luckily it was powered on during the night, so the Windows Home Server (WHS) had a full backup. Had a few probs though:

    - the recovery cd didn’t have network drivers for my LAN card

    - the drivers stored in the special folder on the backup were 64-bit, which isn’t supported by the recovery cd (DUH!!)

    - had to download 32-bit drivers from DELL and put on USB drive

    Tip: make sure your c-drive matches the size of the backup, and create a “dummy” FAT recovery partition on your new HD which mimics the DELL RECOVERY partition. Also, make sure your USB drive is disconnected once you don’t need it anymore. Make sure it’s disconnected before you finish the backup. Also, eject the recovery cd when rebooting, just to be sure! I had to do the restore 3 times before it managed to make my c-drive bootable! Quite annoying…

  • 7-Zip on 64 Bit Windows 7 Beta

    7ziplogo I’m having problems in my 64 bit Windows 7 beta with the built in support for unzipping zip-files containing *lots* of files. It often hangs near the end and I have to reboot to sort things out.

    Downloaded 64 bit version of 7-Zip and it work fine – so far. You might want to try that one out if you have the same problems. Eventually it may also hang, but I’ll try it for a while and shout out if I notice any probs.

  • Writespace in Other Languages

    WritespaceSome time ago I noticed a peak in Writespace downloads and I started to get some emails from people with requests for new features and stuff, which is fun. I saw from the stats that Lifehacker had a couple of articles on Writespace, as well as Danish PC-World, some Japanese site (I have no idea what the site is about :) and a few other places.

    I had no idea if Writespace actually worked in Japanese, but apparently it does!

     

    Writespace on Lifehacker Writespace in Danish   Writespace in Japanese
    Lifehacker.com Pcworld.dk Moongift.jp

    If I get some time for it I’ll release a Word 2003 version and add a few of the requested new features.

  • Fill a Select/Option from Json with jQuery

    aspnetMore jQuery and Json…

    To fill a listbox (select) with items from a Json call.

    I got this helper class to handle the options/items:

    public class SelectOption
    {
        public String Value { get; set; }
        public String Text { get; set; }
    }

    A sample action/method in ASP.NET MVC that returns Json:

    public JsonResult GetJson()
    {
        var list = new List<SelectOption>
                       {
                           new SelectOption { Value = "1", Text = "Aron" },
                           new SelectOption { Value = "2", Text = "Bob" },
                           new SelectOption { Value = "3", Text = "Charlie" },
                           new SelectOption { Value = "4", Text = "David" }
                       };
        return Json(list);
    }

    Some HTML and jQuery to fill the list at page load:

    
        <select id="MyList" />
    
        <script type="text/javascript">
    
            $(document).ready(function() {
                $.getJSON("/Json/GetJson", null, function(data) {
                    $("#MyList").addItems(data);
                });
            });
    
            $.fn.addItems = function(data) {
                return this.each(function() {
                    var list = this;
                    $.each(data, function(index, itemData) {
                        var option = new Option(itemData.Text, itemData.Value);
                        list.add(option);
                    });
                });
            };
    
            $("#MyList").change(function() {
                alert('you selected ' + $(this).val());
            });
    
        </script>
    
  • Json, jQuery and ASP.NET MVC

    aspnetI’m stacking a few things here related to Json, jQuery and ASP.NET MVC so that I can get to them later on.

    JQuery to grab some Json when a web page is loaded:

    $(document).ready(function() {
        $.getJSON("/MyController/MyJsonAction", null, function(data) {
    //do stuff with data here
    }); });

    The smallish code in the ASP.NET MVC controller:

    public JsonResult GetJson()

    {

        return Json(GetList());

    }

    It’s possible to use anonymous types with Json() as well, which is very useful but may be harder to unit test.

  • WCF Certificates with IIS on Windows 7 Beta

    I’ve blogged earlier about the problems with Cassini and WCF on Windows 7 Beta (build 7000) and your best bet is to install IIS locally test your services in there. Now, there might be some problems getting IIS to read your service certificate and my colleague Tomas helped me get things running. I thought I might as well blog it here so that I got it documented…

    Open a VS2008 Command Prompt (I ran it as administrator) and create a certificate, then add it to your local store:

    makecert.exe -sr LocalMachine -ss My -a sha1 -n CN=localhost -sky exchange -pe

    certmgr.exe -add -r LocalMachine -s My -c -n localhost -r CurrentUser -s TrustedPeople

    Then you have to give IIS access to the private part of the certificate and Tomas found some sample code to let you do that. The FindPrivateKey.exe source code is available on MSDN. Keep working on the command prompt:

    FindPrivateKey.exe My LocalMachine -n "CN=localhost"

    Note the output for private key directory and filename, for example:

    Private key directory: C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys

    Private key file name: 288538e27a2aebe9f77d2506bf6c836a_adf55683-4eae-4544-bbd1-d6844a44e538

    Then use them to feed the final call to give the default IIS-user access to the private key, for example:

    CACLS.exe C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\288538e27a2aebe9f77d2506bf6c836a_adf55683-4eae-4544-bbd1-d6844a44e538 /G "IIS_IUSRS":R

    That should be it, and it worked on our machines.

  • Running ASP.NET MVC on Your Windows Home Server

    aspnetRight, so I ran the new Web Platform Installer 2.0 Beta on my WHS and it seems (so far) to have worked out quite well. I created a new MVC website with File->New… and published it over to an MVC-directory on WHS (I have set that up earlier, with a file share and everything).

    Now, the version of IIS on Windows Home Server is IIS 6 (because WHS runs on Windows 2003 kind of), so ASP.NET MVC won’t work right out of the box. I was hoping that the Web Platform Installer would have taken care of that, but apparently not.

    Phil Haack wrote a long, and very detailed blog post about how to set things up on IIS 6, so I’m following that, adding support for the .mvc extension, changing the routes in Global.asax and so on, and voila it works:

    ASP.NET MVC in WHS

    Now, I want to set up extension-less URL’s, which is prettier than having to have that .mvc extension in the URL. Phil cover this in his blog post as well, so I’m adding wildcard mappings, and here goes:

     Extension-less URLs

    Isn’t that just great? I love my home server, maybe I can host my Writespace Clickonce installer on my own server? Not too worried about the load on the server :)

    Watch this space for some sample stuff that will be located on my own server *big grin*

  • Web Platform Installer 2.0 Beta on Windows Home Server

    Web Platform Installer I’ve been thinking of setting up ASP.NET MVC 1.0 on my WHS and also start learning some Silverlight stuff, so I took a risk, went to the Microsoft Web Platform Installer page and clicked on the Beta 2.0 link. Downloaded the installer, marked ASP.NET MVC and the most necessary options and let it go. Should work, right?

    It had to reboot once to get Windows Installer 4.5 in, but it continued to chew on and after a few minutes:

    Done!

    Yay! Now I just have to get an MVC test application on there somehow… brb.

  • IronRuby 0.3 Released

    ironruby Jimmy Schemento just blogged:

    I’m pleased to announce a new release of IronRuby: IronRuby 0.3!

    Staying true to our “Conference-driven development schedule,” this release is in conjunction with MIX ‘09, where Silverlight 3 Beta and ASP.NET MVC 1.0 were announced, to name a few. John Lam spoke at MIX today at 12:30pm in Las Vegas about using dynamic languages in Silverlight for testing, scripting, and application building. And some ASP.NET MVC with IronRuby is thrown in there too.

    You can download IronRuby 0.3 here.

  • Case Switching on CLR Types

    As most .NET developers know, you cannot do case/switch on CLR types and one of the reasons for it was explained pretty well years ago by Peter Hallam on the C# team.

    But there are many cases where you would like to iterate through a list of objects if mixed types and do specific things depending on it’s type. For fun I started to try out different ways to do it, some are better than others but they all do the same thing, more or less. I’m also exploring method extensions, method chaining and lambdas and some of the samples almost started to become fluent and DLS like.

    Note

    Oh, I’m as far from a C# language expert as anyone can be, so there are other ways of doing this I’m sure. The random code below is just me playing around for a simple way of doing case/switching on types that worked in the code I’m currently working on.

    Also, if you would like a derived class to do something special, you normally override a method, send in some parameters and let that code whatever it so special. That’s basic OOD, see the Eat() method in the sample code below. But there are cases where you for one reason or other would not like to do this. Enough of that, this is just for fun.

    A List of Pets

    I was working with a class hierarchy of pets like this:

    namespace TypeCase

    {

        public abstract class Pet

        {

            public string Name { get; set; }

            public abstract void Eat();

     

            public override string ToString()

            {

                return Name;

            }

     

            public Pet Case<T>(Action<T> action) where T : Pet

            {

                if (this is T)

                    action.Invoke((T)this);

     

                return this;

            }

        }

     

        public class Dog : Pet

        {

            public override void Eat()

            {

                Console.WriteLine(Name + " eats cats.");

            }

        }

     

        public class Cat : Pet

        {

            public override void Eat()

            {

                Console.WriteLine(Name + " eats mice.");

            }

        }

    }

     

    We got a Cat and a Dog which are both different types of Pet. They have a Name and they can Eat() which is good enough for testing.

    Creating the List

    I’m creating a simple typed List like this:

                var pets = new List<Pet>

                               {

                                   new Cat { Name = "Morris"},

                                   new Dog { Name = "Buster"}

                               };

    Now we have something to play with. First do something you often see, especially in .NET 1.x code.

    Case Switching on Strings

    It’s perfectly fine to switch on strings, so this is quite common:

                foreach (var pet in pets)

                {

                    switch (pet.GetType().ToString())

                    {

                        case "TypeCase.Cat":

                            Console.WriteLine("A cat called " + pet);

                            break;

                        case "TypeCase.Dog":

                            Console.WriteLine("A dog called " + pet);

                            break;

                    }

                }

    I’m not too fond of this, because you may rename Cat or Dog in the future, or change namespace of “TypeCase” to something else, and even though renaming stuff with Resharper is powerful, strings are often missed. It would have been nice to:

                        case typeof(Cat):

    But that’s not allowed. The case must be a constant.

    If Is

    A much safer way is to use if … else if … and instead of using string comparing, check the type with the is statement. It’s also faster to type:

                foreach (var pet in pets)

                {

                    if (pet is Cat) Console.WriteLine("A cat called " + pet);

                    else if (pet is Dog) Console.WriteLine("A dog called " + pet);

                }

    This code is perfectly fine and I’ve used it many times. But what if I wanted to have a Case-like syntax?

    Method Extension on Type

    I’m thinking of a syntax like this one:

                    pet.GetType().

                        Case(typeof(Cat), () => Console.WriteLine("A cat called " + pet)).

                        Case(typeof(Dog), () => Console.WriteLine("A dog called " + pet));

     

    In this case we’re extending the Type type with a Case method, like this:

        public static class TypeExt

        {

            public static Type Case(this Type t, Type what, Action action)

            {

                if (t == what)

                    action.Invoke();

     

                return t;

            }

        }

    The Action parameter encapsulate the anonymous method we’re sending in, containing the stuff we want to do with the pet in question. In the Case() extension method we’re testing to see if we’re given the right Type and Invoke() the anonymous method if so.

    Important Note: Without going into details, just make sure you don’t fall into a case of “Access to modified closure” when doing for(each) loops around anonymous methods. To be safe, you have to create a local pet-variable outside of the method:

                foreach (var pet in pets)

                {

                    //some code

                    var safePet = pet;

                    pet.GetType().

                        Case(typeof(Cat), () => Console.WriteLine("A cat called " + safePet)).

                        Case(typeof(Dog), () => Console.WriteLine("A dog called " + safePet));

                    //some more code

                }

     

    Better Method Extension on Type

    But I’m not happy with this syntax. If feels more cumbersome than the if…is…if…else… syntax, and whenever you see the use of typeof() in code like this, generics can do some work for you. So I’m going for a syntax like this:

                    pet.GetType().

                        Case<Cat>(obj => Console.WriteLine("A cat called " + pet)).

                        Case<Dog>(obj => Console.WriteLine("A dog called " + pet));

    This requires a new method extension:

        public static class TypeExt

        {

            public static Type Case<T>(this Type t, Action<Type> action)

            {

                if (t == typeof(T))

                    action.Invoke(t);

     

                return t;

            }

        }

    Looks better, but you still risk getting into the issues with modified closure above and I would like to work on the “obj” parameter as if it was the Pet objekt itself, not the Type. Let’s make it even better:

    Even Better Method Extension on Pet

    Now I’m going for a syntax that looks like this:

                foreach (var pet in pets)

                {

                    pet.

                        Case<Cat>(c => Console.WriteLine("A cat called " + c)).

                        Case<Dog>(d => Console.WriteLine("A dog called " + d));

     

                    pet.Eat();

                }

    As you can see, the syntax is cleaner and I can work with the pet object itself as a parameter handled to anonymous method in the lambda statement.

    To do this I have to create a method extension which knows about the Pet class:

        public static class PetExt

        {

            public static Pet Case<T>(this Pet pet, Action<T> action) where T : Pet

            {

                if (pet is T)

                    action.Invoke((T)pet);

     

                return pet;

            }

        }

    It’s not a generic Case Switcher on Type, but it feels good to me and is easy to work with. And you don’t have the issue with access to modified closures with this one.

    Refined Method Extension on List of Pets

    I’m throwing in a final variant here, adding the Case method to the list itself:

                pets.

                    Case((Cat c) =>

                            {

                                Console.WriteLine("A cat called " + c);

                                c.Eat();

                            }).

                    Case<Dog>(d =>

                            {

                                Console.WriteLine("A dog called " + d);

                                d.Eat();

                            });

     

                pets.

                    Case((Cat c) => Console.WriteLine("A cat called " + c)).

                    Case<Dog>(d => Console.WriteLine("A dog called " + d));

     

    As you can see, there are two ways syntactically to provide the type and the simple extension method for this variant looks like this:

        public static class PetListExt

        {

            public static List<Pet> Case<T>(this List<Pet> pets, Action<T> action) where T : Pet

            {

                foreach (var pet in pets)

                {

                    if (pet is T)

                        action.Invoke((T)pet);

                }

     

                return pets;

            }

        }

     

    That’s it. I’ve seen a number of more complex ways to do roughly the same, but I’m not trying to create the ultimate Switch/Case framework, just playing around with c# to create something simple that may make the code easier to read (and fun to code).

  • A Couple of Good Days at Microsoft Sweden TechDays

    It was a pleasant first day at TechDays, held in Västerås by Microsoft Sweden. During the day I met with and talked to people I know from before, people I’ve never met but follow on their blogs and some new acquaintances. Cheers to Samuel Kastberg, Pelle “Pellesoft” Johansson, Tomas Wirén, Johan and the guys at Dropit, Kai Fransson just to mention a few.

    I talked to Johan Lindfors, manager of the Microsoft DPE team in Sweden, who had a good presentation (the best I’ve seen so far actually) on Oslo together with Alan Smith. I ran into Daniel Akenine, chapter president of IASA Sweden and CTO of Microsoft Sweden. It’s always nice to talk to Daniel!

    Later in the evening I talked to Tess Ferrandez and Fredrik Normén about some common mistakes we’ve seen developers do, especially with ASP.NET. Tess had a good talk on the topic earlier that day together with Mikael Deurell, and Fredrik did a good one on what to expect for Silverlight in the future.

    Today I attended two talks with Christian Weyer on WCF and on .NET Services and I got the chance to chat a few minutes about WCF interop and bindings to use with usernamepassword tokens which I will will try out soon.

    Earlier today I also listened to Ivar Jacobsen about “what they don’t teach you about software at school” and it was very entertaining. Ivar is so professional and full of experience and good knowledge it’s amazing and I have so much to thank him for, considering how much help I’ve had from his work on RUP, UML and so on. It was great to meet him.

    The day ended with a session on .NET Services, also by Christian Weyer, which was very, very cool. I have no idea how many moving parts he had going in his demos, but he was doing federated security, services and workflows in cloud and on his machine with azure and he had both .net clients and java clients going and you name it. I have to watch the presentation again when it’s available on the Internet later on.

  • Bad Request With WCF Service in Cassini On Windows 7 Beta

    Windows 7 BetaTrying to run a WCF service in Cassini on your Windows 7 Beta (7000) machine and get this error?

    The remote server returned an unexpected response: (400) Bad Request.

    Unless you’re running your service with basic http binding or with security specifically set to None in your bindings, you will get this security-related error. This problem was confirmed by Microsoft and will (hopefully) be fixed in next Windows 7 release.

    The options you got:

    • Create and run your own service host with code (I’ve been doing this in my integration tests until I tried Cassini and got the error)
    • Use IIS (which I’m going to go for)
    • Self-host it with WcfSvcHost.exe (which I’ve not tried yet)

    Note that you need to add quite a few features to get WCF running in IIS running on Windows 7. See my previous post about this.

    Richard Fennell had the same problems as well as a few others out there brave enough to try out a beta operating system.

  • Turn Windows 7 Features On or Off

    I’m trying to install/add IIS features to my Windows 7 beta build 7000 laptop. You got pretty fine grained control over these features in Windows 7, and it’s not easy to know what you really need. I need to run WCF services on my machine, so I’m turning most things on, including WCF Activation stuff:

    image

    Then I’m adding these things that I think I need for your average ASP.NET application:

    image

    Finally I’m adding the management tools, including the IIS 6 compatibility stuff which I’ve been told is needed to play properly with VS2008:

    image

    Then restart and make sure you got everything in place.

  • My Windows 7 Beta Installation is More Stable Now

    Windows 7 BetaI think I got most things sorted with my Windows 7 Beta installation now. When I uninstalled the “half new” version of Virtual CloneDrive I had, things started to work way, way better. There is now a newer version of Virtual CloneDrive (5.4.2.3 or later) that is reported to work quite well. Until you really need an ISO mounting tool, I suggest you wait installing one!

    Small Issue with Multiple Monitors

    I found a new, small issue though when I got my laptop connected to an external monitor. Sometimes when I start it up from Sleep or Hibernation it fails to display the Desktop properly and I have to bring up the “Change display settings” control dialog and re-apply my setting there to have it redraw the Desktop and Taskbar properly. Not a big deal, and it works properly after that until I put it to Sleep and start it up without the external monitor.

    This is something that I’ve not seen on Vista before anyway, and it sure seems like Windows 7 has more than a few changes around how external displays are managed.

  • Writespace on LifeHacker and Word 2003 Support

    WritespaceWritespace is an open source full screen writing environment, developed with WPF as an add-in for Word 2007 which I host on Codeplex.

    A few days ago I started to get emails from people who had downloaded Writespace and I noticed a huge increase in downloads. Apparently the popular website LifeHacker had written an article about it, which is cool.

    There was also a request for Word 2003 support, so I quickly created a Writespace solution for Word 2003 and added it to the source control over at the Codeplex site. I’m not going to release it yet though. The setup for the Word 2003 version is in there, but I don’t have any experience in packaging/deploying Word 2003 add-ins based on VSTO which ships with VS 2008. Not entirely sure of how to add or make sure the client machine has the Office PIM’s installed on his or her machine for one, and I don’t want to end up with a lot of questions and support :)

    So, if you read this and know how to created a nice Word 2003 add-in setup which includes all things necessary, please contact me.

    Feel free to download the source and build/use/test the Word 2003 version and give me feedback on it.

  • New Windows 7 Features I Just Discovered

    Windows 7 BetaThere are several new features in Windows 7, and as I’ve not had the chance to read about them yet, I keep discovering them as I use the OS in my daily work.

    Note that I would not recommend anyone to use Windows 7 beta on their production/working machine as it’s not stable enough – I always have my old Vista environment close by and all work I do is backed up in real time by Outlook, TFS or Live Sync. Actually Live Sync (or Mesh) is wonderful in this case!

    Docking Windows Using Keys

    The first thing I noticed today was that I could move around the active window to the various Windows 7 “docking points” by pressing WINDOW KEY + ARROW. By doing this, the window can be attached to the left or right side of the screen, or even maximized or minimized by pressing the UP/DOWN keys. If you got multiple monitors, the window will travel over to the other monitor. Neat! It’s a quick way to move programs to the second monitor once you get used to it.

    Live Messenger 2009 Supports Windows 7 “Recent Files”

    Eventually I managed to update and install Messenger to version 2009 and I noticed that it supports the new “Recent Files and Browsing History” feature from the Start Menu. It’s not like you can see the active chat windows (which I first thought), but you can sign out, change your status and such things:

    image 

    I wouldn’t be surprised if a future update of Messenger will let you get to recent chats. That you be more consistent with how this particular feature works with Word, Notepad etc. Not that all Windows 7 programs works this way, but for Messenger it would make sense I think.

  • Windows 7 Beta Issues (Hanging Threads)

    Windows 7 BetaSomething that also seems to be an issue with build 7000 is threads that cannot be killed. Right now I’m stuck in a situation where I cannot open more (file) Explorer windows and I cannot close Internet Explorer. Even though I’m trying to end threads from Task Manager. Looks like this in Task Manager right now:

     

    image

    I’ve had the same problems with the Messenger process that couldn’t be killed. Could be because I’m not running as Admin? Time for a reboot.

    Edit: I have just uninstalled Virtual CloneDrive (5.4.1.1) to see of it was causing problems related to restart and file handling, which some reports indicate. I’ve also downloaded a newer beta version of CloneDrive (5.4.2.3) which should support 64-bit Windows 7 better I’ve heard. Follow the discussion on TechNet.

  • Translating the Domain Language to English

    Fredrik wrote a quite interesting blog post about the translation of the domain into English, even though the company language may be something different:

    I’ve worked on projects where the ubiquitous language became anemic because the developers translated the Norwegian domain into English. Apart from often having trouble finding good translations for many of the domain concepts, the fact that the developers begun calling things by their English names when talking about them often caused misunderstandings between the developers and the domain experts.

    Some interesting comments there on his post. I've been using the, what Fredrik calls, “GetLønnslipp()” method the last couple of years when developing services for customers. We first tried to translate the, in our case, Swedish domain names into English, but some expressions were hard to translate and get an agreement on. So we went for English verbs and Swedish nouns and it has worked out quite well. Felt stupid first, but not any more.

    The best thing is that the data contracts based on XML Schemas have no English in them at all and are therefore very easy to understand and discuss with the customer.

    It would have been a whole different matter if the customer in question already had business with/in other countries and had well known names and terms for the domain. In that case I would have spent some time to get to that English-only Ubiquitous Language.

  • Windows 7 Beta Issues (Explorer and External USB Drives)

    Windows 7 BetaI’m continuing my adventures with Build 7000, and right now the biggest problems I have seems to be related to the File/Windows Explorer itself. I’ve had issues with removing external USB drives. Something seems to hang on to the drive even though it’s removed and I’ve noticed that I cannot do a Windows Restart after that. It hangs on the “Logging off” screen.

    Also, I’ve had problems several times now when copying files from machines on the network and from USB drives. The file copying progress dialog just sits there and refuse to complete. When clicking on dialog Cancel or Close, it tries to cancel but never completes. If I try to kill the dialog from Task Manager, it goes away, Explorer (you know the whole Desktop reboot thingy) restarts but some explorer processes seems to stick.

    Hoping for a newer release soon, build 7000 is just a tad too shaky :)

    If some Windows 7 guy from Microsoft (Jeff?) reads this, can I please have access to a fresh build? *plplplplease*

    But I love the new Task Bar and the option to drag/drop System Tray icons. That part works very well and I hope Microsoft will keep it. Currently I got Outlook new mail notifications and Messenger there together with the standard white (dull colors!!) Windows 7 systray icons.

  • More Setting Up Windows 7

    Windows 7 BetaI keep installing programs on my new Dell m4400 running Windows 7 (build 7000). Unfortunately the “Easy Transfer” didn’t go all the way. I tried to transfer over the network and left it running for 6 hours then shut it off because it seem to hang at 35%. Had to restart the machine to get rid of the transfer window. Maybe a transfer to USB/External hard drive is more stable. Seems that some 75% of my files and settings had transferred properly so I got Outlook and most of my other things moved over ok. I moved the rest of the stuff over manually with a (more or less) major copy/paste from my documents and settings.

    I had to do this twice because there seems to be a glitch with copying many files with this build.

    A couple of times my machine has stopped during restart and require a hard boot. No big deal as long as it is stable while I’m using it – which it is so far. New programs installed (yes, those are tools dear to me):

    • VS2008 Team Explorer – seems to work perfectly
    • TestDriven.Net – runs just fine today, no problems so far
    • Resharper 4.1 – runs just fine as well (phew)
    • Live Writer – installed just fine with the live installer program (messenger didn’t)

    The program I’ve had most problems with today is Messenger 8. It stopped redrawing it’s main window, tried to close it but it refused, tried to kill it and the program closed but the process refused to die. Weird.

    But so far no show stoppers. Too soon to say but it looks pretty good for an early build of a new OS. I’m starting to like the new task bar and everything seems faster than Vista (that’s not hard) but we’ll see what happens once I’ve got a gazillion of programs installed on it.

    The big question is - How do I avoid getting the “spyware” from Adobe and HP on it?!?!

  • Add Domain User to Local Windows 7 Administrators Group

    Windows 7 BetaI just moved my new Windows 7 laptop to the domain and needed to give my domain user local administrator access. I couldn’t find a way to do that via the users and groups tool, but Manoj Nagpal (cool name) blogged about a way to do it in Vista, and it works perfect in Windows 7 as well:

    net localgroup Administrators /add domain\username

    Good stuff. Now I’m about to try “Easy Transfer” to move stuff from my old laptop to the new one. Hope it works…

    Edit: I had to install an updated version of the "easy transfer" program on my old Vista machine, and the transfer started fine. The problem now is that it's been running for 3 hours and the progress bar is kind of stuck at 30-40%. I think I'll let it run for 3-4 hours more before I decide to terminate it and move the files manually. 

  • Setting Up Windows 7 Beta On Dell M4400

    Windows 7 Beta I’ve decided to go for the Windows 7 beta on my new Dell M4400 due to the problems I got with the 64-bit Vista on it. Several blue screens and the most annoying audio stutter made me make up my mind. I must say I got some help from the pro support in the US (the Swedish support people didn’t get back to me at all), and after upgrading and rolling back several drivers things got a bit better, but not perfect.

    So, I downloaded Win 7 Beta from my MSDN subscription, build 7000, and the installation went super. I think it took 18 minutes from start to stop. No issues at all.

    I’m writing this blog post as a log for future re-installs so that I’m not forgetting anything the next time.

    • Screen drivers - Windows Update took care of updating the screen drivers, so I’m on Glass now, and graphics seems to be very responsive. Nice.
    • Anti Virus - McAfee VirusScan Enterprise 8.7i installed nice and seems to run just perfect.
    • ISO Mounting – I usually run Deamon Tools, but people are reporting issues with it so I went for another tool – Virtual CloneDrive. It’s free and has been serving me well on Win 7 so far!
    • Office stuff – Installed Office 2007, OneNote and proofing tools (couldn’t activate Office because I’ve been installing it too many times apparently, duh! A phone call took care of that)
    • Dev stuff – VisualStudio 2008 installed without any problems at all.
    • Chat – For some reason I could not install the latest Live Messenger via the Live installer tool, so I had to download Live Messenger 8 and it seems to work fine.
    • Backup – HomeServer Connector installed just fine. I still haven’t backed it up yet, but I will do that later today once I got a few more programs installed.

    Todo:

    • Dev tools for VisualStudio – ReSharper, TestDriven.NET
    • Dev tools in general – NUnit, Common Service Locator, NHibernate.*, Unity, EntLib… + a bunch more. I have to look at my old laptop to see what I’m missing.
    • Live Sync
    • Etc.

    There must be a way to automate all this?! I’m sure I’ve heard something on Hanselminutes about that. I’ll make sure I keep the downloads on my server so I don’t have to do that all over again.

  • New DELL M4400 Problems Makes Me Mad

    I've been waiting for almost a month for my new DELL M4400 and I got it yesterday. Within some 30 minutes of "getting started" procedures, I got 3 different blue screens, several "recovery from an unexpected reboot error" Vista dialogs and (most annoying of all) audio/sound stuttering problem which gets on my nerves. There are some other minor issues as well, but I can live with those.

    I called the "pro support" which we pay extra for, and that guy was not aware of any audio stuttering problems with the M4400... amazing, Let Me Google It For You. It's been known for months now, but DELL keeps selling it anyway. I hate that. The poor support guy talked to a friend for 5 minutes, came back with a sigh and told me he had to get back to me on this one because there is no simple fix for this. I knew that already, that's why I called them :)

    Still not a word from him, but the day is not yet over.

    I've made a backup on my HomeServer now, and also downloaded the 64-bit Windows 7 beta from MSDN Subscriptions. I've read that some M4400 users have successfully installed Win 7 on their machines and everything runs just fine. I'll first try whatever the support guy suggests, then go for Win 7 and see how that works out.

  • Spotify Stopped and I'm Paralyzed

    I love to listen to music while programming, and I've been using Spotify for a few months now. Most of the music I love and like is in there and they're adding thousands of albums to the catalogue every month.

    Today it stopped working and I'm not sure why, if it's due to firewall changes here where I am at the moment or something else. All of a sudden the program restarted and went into some Update mode:

    image

    which fails:

    image

    I tried downloading the latest version but it still goes into that update thingy. Oh, the horror... I'll have to use Last FM for a while then...

  • Integration Testing WCF Services with Unity

    I've been blogging a few times now about using Unity with WCF, but how do you integration test your service in an easy way without? The way I (and many others) do integration tests for a WCF service is by setting up my own service host and starting the service from test init:

        [TestClass]

        public class ServiceIntegrationTest

        {

            private static ServiceHost serviceHost;

     

            [ClassInitialize]

            public static void MyClassInitialize(TestContext testContext)

            {

                serviceHost = new ServiceHost(typeof(Service1), new [] { new Uri("http://127.0.0.1:8001/") });

                serviceHost.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), "Service1");

                serviceHost.Open();

            }

     

            [ClassCleanup]

            public static void MyClassCleanup()

            {

                serviceHost.Close();

            }

     

            [TestMethod]

            public void Should_get_data()

            {

                var ep = new EndpointAddress("http://127.0.0.1:8001/Service1");

                var proxy = ChannelFactory<IService1>.CreateChannel(new BasicHttpBinding(), ep);

                var data = proxy.GetData(1);

                Assert.IsTrue(data == "You entered: 1", "Got wrong data back, got - '" + data + "'");

            }

        }

    By doing it this way I don't have to make sure Cassini is started up before the test or having to deploy the service to a local IIS. There is no need for web.config or app.config files and I don't have to add any service reference. This way of doing integration testing of services is described by many others, and it should work quite well on a TFS build server or similar.

    Integration Testing WCF Service with Unity

    A few blog posts away I wrote about using Unity with WCF, but how do you integration test a setup like that? Remeber that if you have created your own ServiceHostFactory, you specify the factory to use in the .svc markup using the Factory attribute this:

    <%@ ServiceHost Language="C#" Debug="true" Factory="IRM.Patterns.UnityService.UnityServiceHostFactory" Service="WcfService3.Service1" CodeBehind="Service1.svc.cs" %>

    The "problem" here is that the factory doesn't have any decent public methods to let you create the service host from a given service type. True, there is a CreateServiceHost method which accepts a string representation of the type, but that means your service host factory has to have a reference to the type in question. The way I went around that small issue is by creating a small "harness" around the factory, with a public method which accepts a Type:

        public class UnityServiceHostFactoryHarness : UnityServiceHostFactory

        {

            public ServiceHost CreateServiceHost(Type serviceType, string baseAddress)

            {

                return CreateServiceHost(serviceType, new[]

                                                          {

                                                              new Uri(baseAddress)

                                                          });

            }

        }

    A small change to the test-initialize method makes use of this test-harness:

            [ClassInitialize]

            public static void MyClassInitialize(TestContext testContext)

            {

                var serviceHostFactoryHarness = new UnityServiceHostFactoryHarness();

     

                serviceHost = serviceHostFactoryHarness.CreateServiceHost(typeof(Service1), "http://127.0.0.1:8001/");

                serviceHost.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), "Service1");

                serviceHost.Open();

            }

    Now we're running service integration tests and we have the Unity container loaded as well. I'm sure there are other, smarter and for me uknown ways of achieving the same, but it works for me :) If you want sample code for the UnityServiceHostFactory, please let me know, but know that my code is based on the this sample.

  • ISO Recorder

    This free (Alex accepts PayPal donations) ISO Burner/recorder works pretty well on Vista and got both 32 and 64-bit versions. Quote from his site:

    ISO Recorder is a tool (power toy) ...snip...  to burn CD and DVD images (DVD support is only available on Windows Vista), copy disks, make images of the existing data CDs and DVDs and create ISO images from a content of a disk folder.

    Insert blank DVD, right click on an .iso file and select "open with ISO Recorder" and a few clicks later you got your DVD burned. Just the way I like it.