Simon Green's Developer Blog
Developing .NET in the cold white north ...

Running .NET Apps in 32-bit mode on 64-bit Windows

Monday, 17 December 2007 12:37 by Simon

The normal behavior for .NET 2.0 applications compiled with the default 'Any CPU' platform is to run as 32-bit on x86 (32-bit) Windows and as 64-bit on x64 (64-bit) Windows.

Occasionally, some apps won't run correctly - I've recently run into this with CCNetConfig (a CruiseControl.NET Configuration tool) and have seen it before with other tools. Another obscure scenario where it shows up is if you try to use the JET OleDB driver which will fail in 64-bit mode because there isn't one! (it has to be 32-bit).

Rather than have to recompile the app or even worse, run a 32-bit Virtual Machine, there is an easy way to force .NET to run an app in 32-bit mode using the 'CorFlags.exe' tool.

Depending on your system this may be installed in different places. I've seen it in different places on XP64 and Vista X64:

  • C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\x64\CorFlags.exe
  • C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\Bin\CorFlags.exe

Running this from the command line with the path / filename of the app you want to change and the switch /32BIT+ to turn on 32-bit mode, e.g.:

   CoreFlags.exe TheApp.exe /32BIT+ 

If that fixes the problem then you know that it is a 64-bit issue. You can re-enable 64-bit operation for the app by turning off the 32-bit switch with the parameter /32BIT-, e.g.:

   CoreFlags.exe TheApp.exe /32BIT- 

Voila ... control over 32-bit and 64-bit execution without doing a recompile! I'm not 100% certain but I think that this switch sets the same flag that the 'x86' and 'Any CPU' targets set in Visual Studio.

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:   , ,
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Bootstrap your build - good practice for CruiseControl.NET

Sunday, 16 December 2007 03:43 by Simon

If you are reading this (a developers blog) then chances are you are already in the 20% of developers who know there is more to development than 'developing' (code). So, you are probably using version control such as Subversion, SourceGear Vault or heck, even SourceSafe (for all people knock it, it is infinitely better than nothing at all!) and maybe have a continuous integration system such as CruiseControl.NET or Draco.NET setup to automatically do a build when the source-code changes.

What many people leave out though is making sure that the build scripts themselves and the whole source control configuration is itself protected by version control so that in an emergency a new build machine can be setup quickly and easily without having to develop everything from scratch or remember all the triggers, rules and targets that were in the original system.

Here is a technique that I've found useful and also helps to keep the build configuration for each project with the project that it belongs to (i.e. in it's repository) rather than off somewhere else. It also enables you to make all changes to your build system via the normal Subversion working-copy / commit process.

For this example, lets assume that we have 3 subversion repositories:

The build repository would contain the default CruiseControl.NET files including the ccnet.config file in the server folder which is where the configuration for each project normally resides. We're going to move pieces of that file into each separate project repository.

The CruiseControl.NET wiki describes how to Configure CruiseControl.Net to Automatically Update its Config File which is the bootstrap part of the process - this allows us to make changes to the build config file from another machine without having to get onto the build server and also ensures that all the configuration is stored in a repository.

My ccnt.config file is slightly different to the one shown in the wiki to enable the individual project configurations to be stored in their own repositories so each project has it's own folder:

<!DOCTYPE cruisecontrol [
  &lt;!ENTITY accelerator SYSTEM "file:accelerator\ccnet.config">
  <!ENTITY redirector SYSTEM "file:redirector\ccnet.config">
]>
<cruisecontrol>
  <project name="ccnet">
    <sourcecontrol type="svn">
      <trunkUrl>http://buildserver/svn/build/trunk/CruiseControl.NET/server/config</trunkUrl>
      <workingDirectory>C:\Program Files (x86)\CruiseControl.NET\server\config</workingDirectory>
      <executable>C:\Program Files (x86)\VisualSVN Server\bin\svn.exe</executable>
    </sourcecontrol>
    <triggers>
      <intervalTrigger name="ci" seconds="60" buildCondition="IfModificationExists" />
    </triggers>
  </project>
  &accelerator;
  &redirector;
</cruisecontrol>

 

Remember that the ccservice.exe.config and / or ccnet.exe.config file will need to be changed to tell CruiseControl.NET where to look for the ccnet.config file now that it isn't in the original place:

 <appSettings>
  <!-- Without this appSetting ccservice will look for ccnet.config in its own directory. -->
  <add key="ccnet.config" value=".\config\ccnet.config"/>
  <add key="service.name" value="CCService"/>
  <add key="remoting" value="on"/>
  <add key="ServerLogFilePath" value="ccnet.log"/>
  <!-- Used by the WebDashboard ServerLog plugin to locate the log file produced by the LogFileTraceListener (above) -->
  <add key="ServerLogFileLines" value="100"/>
  <!-- Used by the WebDashboard ServerLog plugin to determine how many lines from the log file should be read -->
  <add key="WatchConfigFile" value="true"/>
  <!-- Turns on or off the file watcher used to monitor the ccnet.config file -->
 </appSettings>

 

The next step is to supply the ccnet.config files for each project which will come from the repositories for those projects.

I've created a 'build' folder in each ...

... and inside that is the ccnet.config project snippet for that project:

  <project name="redirector">
    <workingDirectory>E:\ccnet\redirector</workingDirectory>
    <sourcecontrol type="svn">
      <trunkUrl>http://buildserver/svn/redirector/trunk</trunkUrl>
      <executable>C:\Program Files (x86)\VisualSVN Server\bin\svn.exe</executable>
    </sourcecontrol>
  </project>

 

(the real-life project contains a lot more - labellers, targets etc...)

The final piece to tie everything together is to make these project-specific files part of the config folder that the build ccnet.config file is in above and for this we use the svn:externals facility.

I used TortoiseSVN to add the property to a checked-out copy of the config folder:

NOTE: The screeshot above only shows the first entry. An additional entry would be made for the accelerator project.

After committing all these files the build server will automatically update it's own ccnet.config and get the separate snippet of the file for each project from the separate project repositories because of the svn:externals. The folder structure will then appear as below:

Everything is stored in source control which makes moving to a new build machine easier and the configuration for each project is stored in the same repository as the project itself.

Adding or removing projects from the continuous integration / build system is simply a case of editing the root ccnet.config file and setting the appropriate svn:externals property on the config folder which can be done on a working copy of the build repository. An additional advantage is that all changes can now be done via subversion itself without needing direct access to the build machine so normal repository security can be used.

Incidentally, in case you are wondering what happens if a non-working configuration is committed don't worry - CruiseControl.NET is smart enough to avoid using something that won't load and keeps the previous version in memory so all you need to do is correct it and commit a new working version and it will then pick that up and carry on.

Currently rated 4.7 by 3 people

  • Currently 4.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Ode to the MVC Framework

Sunday, 9 December 2007 13:36 by Simon

We've all been there ... thought we were going to get some code out of the door but then for one reason or another we couldn't manage it. I hope ScottGu et al who worked so hard to try and get it out this weekend don't take this the wrong way but here is a modified version of the lyrics to a song from the musical 'Les Miserables' for all of us who are sooo keen to get our hands on the new framework and waited all weekend for it ...

MVC framework (to 'Les Miserables - Empty Chairs At Empty Tables' music)

[A developer who got his hands on the MVC framework and blogged about it]

There's a grief that can't be spoken
There's a pain goes on and on
Empty pages, empty tables
Now my sites are dead and gone

Here they talked of view-controllers
Here it was they lit the flame
Here they sang about the framework
And the framework never came.

From a blog page in Seattle
They could see a world reborn
And they rose with voices ringing
I can hear them now!
The very code that they had posted
Became their last communion
On the lowly CTP...
At dawn.

Oh my friends, my friends forgive me.

[The ghosts of those who died waiting for the MVC framework appear.]

That I have code and you have none
There's a grief that can't be spoken
There's a pain goes on and on

Phantom frameworks run on windows
Mock assemblies on the floor
Databases with no tables
Where my view will run no more.

[The ghosts fade away.]

Oh my friends, my friends, don't ask me
What your sacrifice was for
Empty projects with no tables
Where my code will run no more...

Ah well, at least I have something to look forward to next week!!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   .NET | MVC
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

MVC Framework for ASP.NET

Sunday, 9 December 2007 04:02 by Simon

The ASP.NET 3.5 Extensions Preview (which includes microsoft's new MVC framework) should be release today on ASP.NET. It was due to ship earlier in the week but due to a bug got delayed. However, the team behind it have been working over the weekend to get it out. I can't wait to get my hands on it.

I've used ASP.NET for development even though I know about the other approaches (Ruby on Rails, Castle etc...) simply because I make a living out of coding and most clients want the big corporate supplied platform. Going into a company and trying to sell Ruby on Rails can be quite difficult and there simply aren't the opportunities / jobs about to justify switching to it (although I can understand people using it on private projects and startups).

Some question whether Microsoft should be producing a copy or clone of what existing open source projects already do. Well, I'm glad they are doing it!

Love em or hate em, Microsoft make some great development tools and platforms / frameworks and using these is how I make a living. 

What I think the ASP.NET MVC framework will do is validate the approach (if it needed it) and also allow it to be used in corporate / enterprise environments - i.e. it will become mainstream and less time will have to be spent selling it to people who really don't know the difference between a MVC and an MCP but don't want to risk their position by allowing some developer or consultant to lead them down the road to a minority used platform.

ScottGu has made some posts about what the MVC framework is and getting started with it which are a great read:

ASP.NET MVC Framework
ASP.NET MVC Framework (Part 1)
ASP.NET MVC Framework (Part 2): URL Routing
ASP.NET MVC Framework (Part 3): Passing ViewData from Controllers to Views
ASP.NET MVC Framework (Part 4): Handling Form Edit and Post Scenarios

Also, some other blog posts provide more detailed information about various aspects:

TDD and Dependency Injection with ASP.NET MVC
ASP.NET MVC Preview: Using The MVC UI Helpers

I can't wait to use this and already have some apps planned to use it ...

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   .NET | MVC
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

NHibernate VistaDB Driver and Dialect

Friday, 7 December 2007 13:35 by Simon

Well, I finally got a bit of spare time and published the NHibernate driver and dialect for VistaDB as a CodePlex project.

As I mentioned in my previous blog entry, VistaDB is really useful even if you only use it during unit testing.

The really great thing about it though is that you can do normal database / NHibernate development and have a simple XCopy deployment which makes application demos very easy (complicated installs and configurations are often a barrier to evaluation and possible sales). Depending on your application and the usage that it gets VistaDB may or may not be up to the task of handling the persistence for the full deployment (it is a file-based database although a proper server version is on the way). With NHibernate though this isn't a worry as the customer is free to use any of the other supported database engines for the deployed version.

I intend to update a forum application I wrote a number of years ago to the new ASP.NET MVC about to be release and use the VistaDB database during development. The current SQL Server database is fairly large (about 4Gb) and has well over 2.5 million posts on it so it should give it a good test - I will let you know how I get on with it.

Currently rated 2.7 by 3 people

  • Currently 2.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , , ,
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed