Nov
27
2010

Mounting a remote Linux folder as a Windows drive through SSH

There are some times in which you need to come to some extreme solutions. Having two days of trials without success to have a portlet running in a local Tomcat with Day portal I came to the following solution.

Shortly why I came to such a solution? I needed to work on some CSS on a portal solution, and the development cycle was taking too long. I had to commit to svn, run a teamcity build which deployed a war to weblogic to finally be able to test my CSS changes. Far too long.

So first idea was to have our portlet working locally in Day portal deployed on Tomcat. After many attempt to have this running, I have stopped with this idea.

Next idea was to work directly on the Linux file system, and modifying the CSS files which would be reloaded automatically by weblogic. Good idea, it was working but I needed more, I needed my development environment.

So I searched a solution to be able to mount a remote Linux folder as Windows drive through SSH. And I quickly found a solution! Thanks to Dokan SSHFS

I finally could fire JetBrains WebStorm on my Windows notebook, edit CSS files which are located on a remote Linux server, save the file and refresh my page on the browser. Straight solution, certainly not the best but at least I could work.

Dokan SSHFS is a great tool! It took me 10 minutes to install it and configure it.

You must take care of:

  • Dokan SSHFS supports only OpenSSH key format. So I used puttygen to convert my key.
  • Dokan SSHFS doesn’t work with Dokan 0.5, you have to use the updated files found on the web page

The rest was just easy! Well done.

Nov
23
2010

“Unable to evaluate the expression” error in Visual Studio 2010 debugger

Last week I had an issue in Visual Studio 2010 debugger in some projects only! When I was looking at the value of variables I was getting an error message saying “Unable to evaluate the expression”!

Searching on Connect I have found that someone else had the same issue! Not really a good sign, “Debuging (Evalutation) stops working at times - Unable to evaluate the expression”. I have the same configuration, same issue and can reproduce what is described:

I'm on Windows 7 64bit and am using VS.NET 2010 Ultimate
Never had a problem with VS.NET 2010 until recently. And the problem I am having is that when I create a new console app and am not able to:
1. Evalutate any variable values
2. Hover over any variables and see their values
3. Use the immidiate window to get any values. I see a message -"Unable to evaluate the expression"
The debugger stops and the break points as expected but the above does not work.
If I switch the Project Build platofrm target property from x86 to Any CPU, then everything works as expected. Switching it back to x86 gives to the same behavior as explained above.
Other project types exhibit the same behavior sometimes. I have a new ASP.NET MVC project that are created and it exhibits the same behaviour. In fact with this project I am unable ot debug no matter what the build settings are.
Older console app projects have this problem as well (they used ot work just fine earlier).

On last Friday, I re-installed two times Visual Studio 2010 without any success, uninstalled all tooling… Still the same issue. I tried several other things over the weekend which didn’t helped.

I finally found that I had installed ASP.NET MVC 3 RC and I remember reading the documentation saying that it had an issue with Async CTP, which cannot be installed together on the same machine.

So I un-installed ASP.NET MVC 3 RC and searched Async CTP which wasn’t listed. Something I did already when installing ASP.NET MVC 3 RC.

This morning I realized why I didn’t found the Async CTP when I installed ASP.NET MVC 3 RC! It is installed as an update! What’s the hell!

So from Control Panel you have to click on “View installed updates” to see it

And now you can see it and un-install the Async CTP

Then I followed the instruction of Drew Miller of the ASP.NET Team to uninstall all pieces of ASP.NET MVC 3 RC, “How to Uninstall Microsoft ASP.NET MVC 3 RC

Now my Visual Studio 2010 debugger is working like before!

Nov
19
2010

Using Resharper Search with Pattern to protect you from your code

Today I faced a nasty bug, a null pointer exception in a property databound to our WPF application. This had some nasty side effects, and for sure this part of the code didn’t had any unit test, too bad! For sure now it has.

The line of code was really simple

Values.Where(model => model.IsSelected).FirstOrDefault().Refresh();

I guess you see the issue! If not here is the MSDN documentation:

public static TSource FirstOrDefault< TSource >(this [NotNull] IEnumerable<TSource> source)
in class Enumerable

Summary:

Returns the first element of a sequence, or a default value if the sequence contains no elements.

Parameters:

source:
The IEnumerable<out T> to return the first element of.

Type Parameters:

TSource:
The type of the elements of source.

Returns:

default(TSource) if source is empty; otherwise, the first element in source.

Exceptions:

ArgumentNullException:
source is null.

Yeah, FirstOrDefault might returns null, so if you chain a call to another method it just crash!

For sure we know that! We use this method for that purpose, but an error can happen that fast!

So I decided that I wanted to be protected by my tooling. So I went back to read the post “Introducing ReSharper 5.0: Structural Search and Replace

After several trial and some help from Ilya (Thanks!) I finally found the correct way to express what I wanted. My goal was to find all code which uses FirstOrDefault() method followed by a call to another method. Exactly like my issue.

$enumerable$.FirstOrDefault().$method$()

enumerable is an Expression of type System.Collections.IEnumerable or derived type

method is a identifier placeholder with an empty indentifier name regexp

I then verified that this error was found. And also luckily that this was the only error of that kind in our application.

Then I finally added it to the Resharper Pattern Catalog, to show a warning.

Now when ever I will type this stupid thing, I will have my preferred tool Resharper, telling me how stupid I am to even try this!

BY the way you might download a sample Pattern Catalog from this blog post “Sample SSR Pattern Catalog Available for Download”. There are some cool stuff in there and it might help writing your owns.

Nov
9
2010

Sample BDD web test using easyb and sahi

I blogged yesterday about “BDD web application testing using easyB and Sahi

I was asked to provide a sample, so here it is!

Click the picture to see full size

Nov
8
2010

BDD web application testing using easyB and Sahi

I already talked about the way we are testing our web application at Jobping in the following posts “ASP.NET MVC 2, MSpec and Watin ” and ”Automated functional tests using Watin and MSpec”.

The other day I landed on the DZone page “Automated Browser Testing: What's in Your Toolkit?” In the list of around 10 tools I knew some of them but there were 3 I didn’t knew. So I decided to go on and read about those 3. In this list there were Sahi which got me with those three sentences:

  • Powerful Recorder works on any Browser
  • Robust object identification without brittle XPaths
  • Implicit waits - even for complex AJAX applications

This is supposed to solve the issue we currently have with Selenium, even if we use Screen Objects to encapsulate our Selenium tests. It is just a pain to work in our highly AJAX application and for sure the XPath are brittle. 

So I decided to try it. I started by watching the video in the “Get Started” section and in less than 10 minutes I had my first test running.

WOW ! Impressive.

Going further I wanted to know if it could be used with a BDD framework. We currently are using JBehave, but reading about it, it was clear that it would be more effort for me to try it. So I went back to easyb  which I tried out a couple month ago.

I used Sahi Java Driver to output some Java code which I used directly in my easyb story.

I was surprised and impressed about the easiness I went through the implementation.

Looking forward for the next steps and where we will end with this.

Nov
6
2010

Starting with Mercurial distributed source control management tool on Windows

I am starting to use Mercurialfor my personal projects. At the moment I use it only locally to be able to experience it but also to be able to try thing and revert easily to previous state.

To get started I downloaded

This let me work directly from a PowerShell window, Windows Explorer or Visual Studio.

To add a project to Mercurial from the PowerShell I used the following commands:

PS E:\Personal\Projects\_Spikes\DynApplication> hg init

Then I created in the same folder a file named .hgignore, excluding file or folder which I don’t want to version in my C# project:

syntax: glob

*.csproj.user
obj/
bin/
*.ncb
*.suo
_ReSharper.*
*.ReSharper.user
*.TeamCity.user

You are ready then to add files of your project to Mercurial with

PS E:\Personal\Projects\_Spikes\DynApplication> hg add

Then you need to commit the files

PS E:\Personal\Projects\_Spikes\DynApplication> hg commit –m “Initital commit”

That’s it your files are under Mercurial source control.

To get started with Mercurial I recommend you to read Hg Init: a Mercurial tutorial!

If you need some hosting there is bitbucket, which has been bought by Atlassian recently. And it is free for 5 users. For more user you will have to pay, but it is a reasonable price.
You might also use Codeplex for your open source project which supports Mercurial !

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent was awarded Most Valuable Professional (MVP) by Microsoft from April 2002 to April 2012.

JetBrains Academy Member
Certified ScrumMaster
My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List