Finally - stuff for the Vista Ultima users (insert irony here)

May 2, 2008 at 11:51 AMAndre Loker

Many users of Vista Ultimate have complained that Microsoft did not release a lot of useful extras exclusively to Ultimate users. To sum it up, until now, we got:

  • DreamScene. Call me ignorant, but actually I am not sitting in front of my PC watching videos that play on my desktop all day long.
  • BitLocker and EFS extensions. Although I am not using BitLocker nor EFS, let alone the extensions, this extra might be of some use.
  • Texas Hold'em Poker. No comment...

But today I found a new entry in Windows Update: *drumroll* two brand new sound schemes called "Glass" and "Pearls" provided exclusively to Ultimate users! Hooray!

If someone noticed irony in the previous paragraph it's no coincidence. Really, of all the nifty things that MS could have thought up, two new sound schemes are disappointing to say the least. It is not only that I don't use sound schemes at all. The two schemes are not that spectacular in the first place. Oh, by the way, for those who really don't have anything else to do than watching DreamScene videos, there is some new content available as well.

Come on Microsoft, I know you can do (much) better than this!

Posted in: Windows

Tags: , ,

MonoRail: Mapping root directory to specific controller and action

April 28, 2008 at 2:38 PMAndre Loker

Most often, you want a web application to transfer the user to a specific controller action when he or she accesses the root directory of your application. For example, if the user entered http://somedomain/TheWebApp you'd want the app to handle it as if the user entered http://somedomain/TheWebApp/Home/Index.

In MonoRail this can be easily achieved using the built in URL rewriting service. Setting up the configuration is a matter of two steps:

1. Enable rewriting rules for the application

To enable url rewriting in the first place, you will have to add a specific IHttpModule in your web.config. It should be the first module in the <system.web><httpModules> section to ensure proper working.

   1: <system.web>
   2:   <!-- other stuff -->
   3:   <httpModules>
   4:     <add name="routing" type="Castle.MonoRail.Framework.RoutingModule, Castle.MonoRail.Framework" />
   5:     <!-- other modules -->
   6:   </httpModules>
   7:   <!-- other stuff -->
   8: </system.web>


2. Configure rewriting rules

In your <monorail> section in web.config or - if you are like me - in the external monorail configuration file add a <routing> section like this:

   1: <routing excludeAppPath="true">
   2:   <rule>
   3:     <pattern>^/?$</pattern>
   4:     <replace>/home/index</replace>
   5:   </rule>
   6: </routing>

This section contains only one rule, that will rewrite any request that targets the root directory of the application (either with or without a trailing slash) to the index action of the home controller. Of course, you may fill in whatever route fits your needs.

If you are not familiar with regular expressions: the pattern ^/?$ can be read like this: the whole url (from the start ^ to the end $) must be either empty or may optionally consist of one slash (? means: the slash is optional).

The excludeAppPath attribute makes your life much easier if the app exists in a subdirectory instead of the root directory. It simply means that you may write your rules as if all urls are targeted at the root directory. Otherwise, you would have to write:

   1: <routing excludeAppPath="false">
   2:   <rule>
   3:     <pattern>^/TheWebApp/?$</pattern>
   4:     <replace>/TheWebApp/home/index</replace>
   5:   </rule>
   6: </routing>

This would be a lot harder to maintain and deploy.

Some notes:

  • The pattern does not match the query string part, so http://somedomain/TheWebApp/?foo=bar would still be correctly rewritten to /home/index
  • The query string is passed to the rewritten URL as well, so (in the example above), the query parameter foo would be usable in the Home controller
  • I work with the subversion repository trunk of the castle project, so I cannot guarantee that this works for the current officially released version (RC3 as of now) or that it will work in the future.

Posted in: Snippets | Castle

Tags: , ,

VS web app: System.Runtime.InteropServices.COMException

April 28, 2008 at 10:41 AMAndre Loker


Two minutes ago I opened a solution in VS 2008 that contained a web app project. An error message box popped up saying "System.Runtime.InteropServices.COMException". The web app project was not loaded and could not be reloaded afterwards, either. I was slightly confused because I had worked on the project successfully yesterday.

Then I realized what has changed since the last time I ran VS: yesterday I had opened the solution in a VS instance that ran under the administrator account. I had then changed the web app’s properties to let it use IIS instead of the internal web server. Opening the modified solution in a non-privileged instance of VS today caused the error. After undoing the web properties in a privileged Visual Studio instance the project loaded correctly in the non-privileged instance as well.

Posted in: Visual Studio

Tags: ,

Where T : Enum?

April 17, 2008 at 6:13 PMAndre Loker

Mir ist nicht klar, warum C# bei den Constraints von generischen Typen und Methoden manchmal so pingelig ist, obwohl die CLR die entsprechenden Constraints erlaubt.

Beispiel: folgender Code ist in C# nicht kompilierbar

   1: class X {
   2:     public void MachWas<T>(T foo) where T : Enum {
   3:     }
   4: }

error CS0702: Constraint cannot be special class 'System.Enum'

In C++/CLI kein Problem:

   1: ref class X {
   2:     generic<typename T> where T : System::Enum
   3:     void MachWas( T foo) {
   4:     }
   5: };

Posted in: Snippets

Tags: , ,

Web Deployment Projects in Visual Studio 2008

April 14, 2008 at 10:27 PMAndre Loker

Seit kurzem hatte ich das Problem, dass beim Öffnen von Projektmappen, die ein oder mehrere Web Deployment Projects enthielten, jedes Mal der Conversion Wizard von Visual Studio erschien, um das Projekt in das "aktuelle" Format zu übertragen.

Offensichtlich war ich damit nicht alleine, wie aus den Kommentaren der WDP Ankündigung zu lesen war. Glücklicherweise bot Vishal R. Joshi an, auf Anfrage per Mail eine gepatchte DLL zu versenden, mit der das Problem behoben werden sollte. Gesagt, getan. Innerhalb weniger Stunden erhielt ich eine freundliche Mail von Herrn Joshi inklusive der DLL. Mit letzterer brauchte nur noch die ältere Version in %Program Files%\Microsoft Visual Studio 9.0\Common7\Packages überschrieben werden. Und siehe da: der Conversion Wizard erscheint nicht mehr.

Vielen Dank an Vishal R. Joshi für seine schnelle und freundliche Unterstützung. Vermutlich wird eine Lösung für das Problem kurzfristig auch offiziell veröffentlicht. Laut Mr Joshi gibt es zurzeit lediglich noch einige logistische Verzögerungen.

Posted in: Tools | Visual Studio

Tags: ,