# Changing Folders In PowerShell

I really like PowerShell more and more lately. So at no surprise to me, I get better at using it every day. Today I made my own level-up at folder switching. Consider the following folder structure as an example:

So there are two alpha folders inside my samplefolder containing another folder each. So my PowerShell command line is at the samplefolder and I want to get into the gamma folder. I would have done the following in the past:

D:\samplefolder> cd<tab><tab> D:\samplefolder> cd .\alpha2<enter> D:\samplefolder> cd <tab> D:\samplefolder\alpha2> cd .\gamma<enter> D:\samplefolder\alpha2\gamma> <done!>

As you may have noticed, I represented the special keystrokes in angle brackets. After doing this first way of navigating for many years now (because it works in cmd.exe as well) I learned, you could provide a filter expression before pressing tab:

cd a<tab><tab>

This would only go through all possible subfolders starting with an “a”. Of course, in this sample, this provides no use, but you can use the star as well:

cd *2<tab>

This expands to:

cd .\alpha2

Nice! We saved a tab keystroke, but we can do even better. If you are certain, your filter will correctly expand, you do not have to press tab first, but you can simply press enter:

D:\samplefolder> cd *2<enter> D:\samplefolder\alpha2>

Wow! But we can do even better but before, we have to go one step back: What you also could do is changing into more than one directory deep at a time:

D:\samplefolder> cd .\alpha2\gamma<enter> D:\samplefolder\alpha2\gamma>

And as you might already guessed by now, the filters work here as well:

D:\samplefolder> cd a*2\g*<enter> D:\samplefolder\alpha2\gamma>

But I left the most crazy example for last: Consider the case, where you want to change to the gamma folder, but you do not know the correct alpha folder. You don’t have to!

D:\samplefolder> cd *\gamma<enter> D:\samplefolder\alpha2\gamma>

PowerShell is smart enough to change into the right directory for you. Impressive!

Most of this stuff shown does not work in cmd.exe but why would you want to use cmd.exe anyway anymore?

# On The Technical Health Of Fabse.Net

As some of you noticed, my blog was not available for about a day. There were actually two unrelated issues in a row affecting the availability of my blog.

The first one was related to Windows Update on my VM. There was some updating done but there was an outstanding restart. This somehow broke the connectivity between WordPress and MySQL. I am using WP Super Cache as a plugin for WordPress to cache all pages locally and so this database issue was going unnoticedd to most users except the Googlebot. It looks like requesting the robots.txt is not cached at all by WordPress. Google Webmaster Tools was sending emails to me notifying me about the issue of not being able to access the robots.txt file and postponing the indexing. At this point I simply restarted the virtual machine and it worked again. Have you tried turning it off and back on again?

My blog runs on a small VM in Microsoft Azure and the Azure storage in West Europe had a reduced availability yesterday affecting the VMs as well. Whatever reduced availability means. As a matter of fact, my VM was listed as running, but I could neither access my site nor could I RDP into it.

Microsoft requires at least two running VM instances in an availability set for their SLA to kick in. I am running only a single one to safe money. So I think it was actually my own fault/risk.

Regarding the near feature, I want to look into increasing the availability while reducing costs at the same time. I will definitely write about it here.

# Add Gacutil To The External Tools List Of Visual Studio

I often have the need to rapidly add my build output to the global assembly cache of .Net. You can do this using a post build event but it really is not ideal. Therefore I added the gacutil command as an external command.

If you want to do this, you first have to figure out the location of your gacutil.exe. Please open the “Developer Command Prompt for Visual Studio”. You can then type “where gacutil” and it will tell you the location(s) of your executable.

Then you switch back to Visual Studio and select the “Tools” menu. Then “External Tools…”.

Click Add to insert a new Item and set it to the following values. Please notice the different argument values for installing and uninstalling from the GAC.

Title: Install to GAC
Command: C:\Program Files (x86)\...\gacutil.exe
Arguments: -i $(TargetPath) Title: Uninstall from GAC Command: C:\Program Files (x86)\...\gacutil.exe Arguments: -u$(TargetName)


…and remember to replace the location of gacutil with your own as the command.

# BizTalk WCF Service Publishing Wizard: World Wide Web service (W3SVC) on host "localhost" not available.

I tried to publish an orchestration using the WCF service publishing wizard and observed the following error:

And after clicking next I only observed:

Invalid project location “http://localhost/VIP.Orchestrations.ContractPositionProcessor”.

(Microsoft.BizTalk.Adapter.Wcf.Publishing.WebDirectory.WebDirectoryException) World Wide Web service (W3SVC) on host “localhost” not available.

The following Windows component may not be installed: Application Server -> Internet Information Services (IIS) -> Common Files.

Unknown error (0×80005000)

(System.Runtime.InteropServices.COMException) Unknown error (0×80005000)

The fix is to use the Server Manager to install the IIS 6 management compatibility feature:

Restarting the publishing wizard now works as expected:

# Doing Transactions In Oracle Like You Know Them From SQL Server

I know how to do transactions in SQL Server. It is really easy, at least for me. In ORACLE, the keywords are slightly different and you have to use semicolons at the end of each statement. You also have to name your transaction but an empty string will do just fine.

Compare this for yourself:

--Oracle
set transaction name 'mytransaction';
update mytable set somecolumn = 'some value' where id = 22;
commit;
--SQL Server
begin tran
update mytable set somecolumn = 'some value' where id = 22
commit

# Correct Parameters For The BaseFunctoid.SetupResourceAssembly Method

If you are writing your own BizTalk Functoid you have to provide information about your Ressources used to describe your functoid name, details and icon. For this task, you have to call the SetupResourceAssembly function in your functoid constructor. Okay, but what are the correct parameter values? The MSDN article is not only not good but plain wrong.

resAsmName does NOT expect the name of the assembly, but the full qualified name of your resource dictionary.

If your resource is in your Project root folder and is called “Resource.resx” and your project has a default namespace of “My.Company.SuperFunctoid” than you would provide the value “My.Company.SuperFunctoid.Resource” as the value of the first parameter.

The second parameter is the assembly, which contains the resource dictionary. Here you could do Assembly.GetExecutingAssembly() to get it.

To make this more refactoring safe, I would suggest the following call instead:

This way, you can change your default namespace without fear of breaking “magic” strings.

# Published my first printed article

I published an article! Cool, isn’t it? You can find it in web&mobile developer issue 01/14 (german). It was an interesting experience writing this article as I was writing about a subject which I am interested in myself for quite some time.

I am describing a way to collect telemetry data from a Windows Phone application and sending them back to a backend service. I am focusing my article around doing this in a decoupled fashion through the usage of Windows Azure ServiceBus Queues. The goal is to get some data to get insights in the way the users use an app like “How long do they run the app?”, “How often do they start the app?” or “Did they used feature x?”.

# OLTP or OLPC?

and

OLPC is One Laptop Per Child

They are completely different things, but I somehow mix them now and then. Weird!

# Writing ‘throw ex;’ is almost always wrong!

So what is the difference between ‘throw ex;’ and ‘throw;’ in C#? The first statement recreates the stack trace while the latter one preserves it. Consider the following method, which will throw an exception if it gets called:

<span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Inner()
{
<span class="kwrd">throw</span> <span class="kwrd">new</span> Exception();
}

And then you have two different methods implementing the two different coding styles:

<span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Rethrow()
{
<span class="kwrd">try</span>
{
Inner();
}
<span class="kwrd">catch</span> (Exception ex)
{
<strong><span class="kwrd">throw</span>;</strong>
}
}

<span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> ThrowEx()
{
<span class="kwrd">try</span>
{
Inner();
}
<span class="kwrd">catch</span> (Exception ex)
{
<strong><span class="kwrd">throw</span> ex;</strong>
}
}

At last, you have a short console application to call both methods and print their stack trace:

<span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
{
<span class="kwrd">try</span>
{
<strong> ThrowEx();</strong>
}
<span class="kwrd">catch</span> (Exception ex)
{
PrintEx(ex);
}
<span class="rem">//...</span>
<span class="kwrd">try</span>
{
<strong> Rethrow();</strong>
}
<span class="kwrd">catch</span> (Exception ex)
{
PrintEx(ex);
}
}

Here is the output:

As you can see, ‘throw;’ preserves the actual location, where the exception really was thrown.

There is hardly any case where you want to hide the actual location of an error, so the best is to just use ‘throw;’ as your default in a catch clause.

# Things I Learned Today

I decided to just write down the stuff, I learned today in a random order, to let you know and (maybe) let you learn as well!

• I really like the whisper sync inside the kindle apps and devices and today I learned about Calibre which can do the same thing but with many more devices. It can also convert your ebooks to the appropriate formats.
• Even if your company uses Subversion for version control, you can still use git locally in a fully Git and Other Systems – Git and Subversion.
• Does the new XBOX One plays XBOX 360 games? No.