Dan Byström’s Bwain

Blog without an interesting name

The åäö Ghost Strikes… AGAIN!

Posted by Dan Byström on July 25, 2007

Just when I thought we were out of the dark ages… something hit me right out of the blue.

During the summer something strange has happened, which I suspect happened because of some Microsoft security update. That is at least more probable than an ill-willing gnome in my machine fiddling with some bits. But you never know.

What has happened is that the

System.Windows.Forms.Application.ExecutablePath

property all of a sudden returns an incorrect result if the path contains a “non-ASCII” character like our swedish charaters åäö!!!

Replacing it with a

System.Reflection.Assembly.GetExecutingAssembly().Location

fixes the problem.

Demonstration:

  1. Fire up a new windows forms project and add “MessageBox.Show( Application.ExecutablePath );” to the default form’s constructor.
  2. Compile and place the exe in a folder called “c:\Our Application”.
  3. Run and you get “C:\Our Application\WindowsApplication1.exe”.
  4. Now rename the folder to “c:\Vår Applikation”.
  5. Run and you get “C:\V�r Applikation\WindowsApplication1.exe”. Where the “�” character is #65533.

The scary thing is that this behavior just changed over night.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: