Posted by: joachimvandenbogaert | June 4, 2009

Deploying WCF on IIS 6.0 with Certificates, NHibernate and Membership

Get a server that allows you to run .NET 3.5

In most cases you will get a Windows Server that is configured with .NET 3.0, so you will first have to install .NET 3.5 on it in order to use WCF. This is not so difficult, but you need to have the right configuration. From 3.0. .NET 3.5 does not install automatically. You have to make sure that you have Windows Installer 4.5 installed, which you can find here

.NET 3.5 can (redistributable package) be found here

Configure ASP.NET and WCF for IIS 6.0

Next, open a command line window and go to the Microsoft.NET directory (typically C:\Windows\Microsoft.Net\Framework or C:\Windows\Microsoft.Net\Framework64).

  • Go to the v2.0.50727 dir and run aspnet_regiis -i
  • Go to the v3.0\Windows Communication Foundation dir and run ServiceModelReg -i
  • Make sure that ASP.NET 2 Web Service extensions are allowed, otherwise you will get a 404 error when opening an svc file.  In the IIS management console, click [Web Server Extensions] and make sure that ASP.NET v2.0.507272 is set to [Allowed]




Configure the host header in order to publish the correct host on the svc web page: open the IIS management console, right-click your website, select [Properties] and on the [Web Site] tab click the [Advanced …] button.

Web Site Properties

Web Site Properties

This brings up a new dialog. Click the ip-address for wgich you want to change the identification from localhost to the web site’s ip-address and click the [Edit …] button.

Advanced Web Site Identification

Advanced Web Site Identification

Now you can edit the [Host Header value] field. Click [OK] to accept the changes.

Edit Web Site Identification

Edit Web Site Identification

Configuring Postgres to allow your website to access your databases

If you followed the described procedure, you change your website’s id for some applications from “localhost” to whichever ip-address you are using. It took me some time to figure out what was going on, but apparently Postgres complains about access rights, not configured in pg_hba.conf. So if you want to do this, make sure you add an entry in pg_hba.conf, for example:

host all all password

this will allow the host with the IP-address to access postgres using password credentials.

Posted by: joachimvandenbogaert | April 1, 2009

Vista networking fails after connection to VPN


The solution to this problem can be found here:

  1. Bring up the properties of your VPN connection and select the [Networking] tab.
  2. Select the Internet Protocol Version 4 or 6 Properties and click the [Advanced] button.
  3. Make sure that [Use default gateway on remote network] is not checked.
  4. Click the [OK] button to save your settings.
Posted by: joachimvandenbogaert | March 26, 2009

R and C# on Windows

The following page offers a good introduction, but some information is missing. So I thought it would be useful to add some more instructions, especially for deployment on client systems on which R has not been installed yet.

Here’s a list of issues:

  1. R requires Administrator rights when you install it (as described in the R Administration guide). This also applies when you want to install add-ons. R itself does not have these permissions, so if you install an add-on from within R, you will get an “access denied” error (to install an add-on, you can use the R gui,  Packages->Install package(s) …). A workaround is to make the R program directory writable to everyone. Maybe you can also try to run R itself as administrator when you need to install a package, but I haven’t tried this yet. This would probably be a better solution.
  2. Anyway, on windows, the install procedure is not actually an install procedure. You only get a zip file in a temporary directory. So to really install an add-on, you need to copy the extracted add-on folder and copy it to the Rlibrary. Note that this also requires write access to the R installtion folder.

Here’s a summary of what you need to do to get R working:

  1. Download the rscproxy package, unzip it and install the rscproxy directory in your Rlibrary directory.
  2. Download R_Scilab_DCOM3.0-1B5.exe from (you coulds also use another mirror), and install it.
  3. To use R, add a reference to your C# project to STATCONNECTORCLNTLib, StatConnectorCommonLib, and STATCONNECTORSRVLib (this is to get full functionality, for the client to work, you only need STATCONNECTORSRVLib).
  4. Use the STATCONNECTORSRVLib.StatConnectorClass to interface with R.

Here’s some example code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

//COM references
using StatConnectorCommonLib;
using System.IO;

namespace RConnector.Tests.Integration
public class TestConnectivityWithR

public void Open_Close()
StatConnectorClass RConnector = new StatConnectorClass();

public void Send_Receive_Data_()
StatConnectorClass RConnector = new StatConnectorClass();
// Data we are going to pass
int n = 20;
// Cast C# type to R type
RConnector.SetSymbol(“n1”, n); 
// The cast value n to n1 is now being used in R
RConnector.Evaluate(“x1 <- rnorm(n1)”); 
// We get back the value of x1, but it needs to be cast
// to an array of doubles
object o = RConnector.GetSymbol(“x1”);
double[] random = (double[])o;
foreach (double d in random)

public void Plot_CSharpInput_Simple()
StatConnectorClass RConnector = new StatConnectorClass();
double[] input = new double[] { 1.0, 2.0, 3.0, 2.0, 1.0};
“input”, input);
“savePlot(filename = \”” +
@”C:\\Users\\Joachim\\Documents\\Debug\\Plot_CSharpInput.eps” + “\”, ” + 
“type = \”eps\”, device = dev.cur(), restoreConsole = TRUE )”
        [Test] public void Plot_CSharpInput_Simple_WithColors_Rainbow()
            StatConnectorClass RConnector = new StatConnectorClass();
            double[] input = new double[] {1.0, 2.0, 3.0, 2.0, 1.0};
            RConnector.SetSymbol(“input”, input);
            RConnector.EvaluateNoReturn(“barplot(input, main=\”Foobar\”, xlab=\”Value\”, ylab=\”Frequency\”, col=rainbow(7))”);
            RConnector.EvaluateNoReturn(“legend(\”topleft\”, c(\”Hello\”, \”World\”), cex=0.6, bty=\”n\”, fill=rainbow(5))”);
                “savePlot(filename = \”” +
                @”C:\\Users\\Joachim\\Documents\\Debug\\Plot_CSharpInput.eps” + “\”, “ +
                “type = \”eps\”, device = dev.cur(), restoreConsole = TRUE )”);
Posted by: joachimvandenbogaert | February 20, 2009

RCOM and C#: SafeArrayTypeMismatchException

R only only accepts safe arrays. In C#, for example the use of jagged arrays is not allowed when passing them to R:

StatConnectorClass RConnector = new StatConnectorClass();
double[] input = new double[3][];filling the array and then doing:RConnector.SetSymbol(“input”, input);

will throw an error, even if all the double[] arrays in input have the same length. Instead, you need to use the Array class.

StatConnectorClass RConnector = new StatConnectorClass();
Array mySafeArray = Array.CreateInstance(typeof(double), 5, 2);for (int i = 0; i < 5; i ++)
     for (int j = 0; j < 2; j++)
        mySafeArray.SetValue(i * j, i, j);
“input”, mySafeArray);

Posted by: joachimvandenbogaert | February 18, 2009

Aspnet_regsql problem

To deploy a Microsoft MembershipProvider, you can use the aspnet_regsql tool to create a membership database for ASP.Net.

SQL Server (Express Edition) is not configured by default to accept remote connections, so you need some configuration changes.

Here’s how to do it:

Unfortunately, aspnet_regsql kept complaining. The cause was something really trivial (the database instance name was missing in the GUI). Just fill out the database name + instance and all will work well, as described here:

Posted by: joachimvandenbogaert | November 21, 2008

Trados 6.5 Tmx importer bug – (35000): SSYacc0103e: Attempted read past eof

Trados complains if you want to import a Tmx file that you have created yourself programmatically (in my case C# with LINQ to xml). As it appears, the <emptyelement/> syntax is not recognised. so you need to add a dummy value to an element in order to get the <emptyelement></emptyelement> syntax.

It took me quite some time to figure this out until I added an empty <prop/> element and Trados 6.5 complained about an illegal token.

So this is the code to create an empty Tmx file – note that I have all my element names and attribute names in separate classes in order to not make typo mistakes:

XDocument m_XDocument;

m_XDocument = new XDocument();
m_XDocument.Declaration =
new XDeclaration(“1.0”, “utf-8”, “yes”);
new XElement(TmxElements.Tmx, 
new XAttribute(TmxAttributes.Version, “1.4”), 
new XElement(TmxElements.Header, 
new XAttribute(TmxAttributes.CreationTool, “Your.Tool.Name”), 
new XAttribute(TmxAttributes.CreationToolVersion, “1.0”), 
new XAttribute(TmxAttributes.SegType, TmxSegmentTypes.Sentence), 
new XAttribute(TmxAttributes.O_Tmf, “TW4Win 2.0 Format”), 
new XAttribute(TmxAttributes.AdminLang, CultureInfo.GetCultureInfoByIetfLanguageTag(“EN-US”).IetfLanguageTag), 
new XAttribute(TmxAttributes.SrcLang, sourceCultureInfo.IetfLanguageTag), 
new XAttribute(TmxAttributes.DataType, “rtf”), 
new XAttribute(TmxAttributes.CreationDate, DateTime.Now.ToString(“yyyyMMddTHHmmssZ”)), 
// Here is the empty element!
new XAttribute(TmxAttributes.CreationId, Environment.UserName), string.Empty), 
new XElement(TmxElements.Body)));

Posted by: joachimvandenbogaert | November 6, 2008

NHibernate and Postgresql: ERROR 42P01

I was setting up NHibernate 2.0.1 with Postgresql 8.3 and Npgsql1.0.1 for .NET 2.0.

I followed the example from the documentation, set up a POCO class and wrote my mapping file correctly, but as it turned out. I kept receiving error 42P01 which states that relation “n” does not exist.

The error had nothing to do with a non-existent table, but with a configuration file example on:

The solution to the problem is on the same page (if you look well enough, that is):

The connection string should read “database=” instead of “initial catalog=”
Unfortunately the example has not been updated at the time of writing.

So here is a corrected version

<?xml version=”1.0″ encoding=”utf-8″?>
<hibernate-configuration  xmlns=”urn:nhibernate-configuration-2.2″ >
    <session-factory name=”NHibernate.Test”>
        <property name=”connection.provider”>NHibernate.Connection.DriverConnectionProvider</property>
        <property name=”connection.driver_class”>NHibernate.Driver.NpgsqlDriver</property>
        <property name=”connection.connection_string”>
            Server=localhost;database=nhibernate;User ID=nhibernate;Password=********;
        <property name=”dialect”>NHibernate.Dialect.PostgreSQLDialect</property>

Posted by: joachimvandenbogaert | October 30, 2008

InstallShield Scripting Engine Missing: Error 1607

On newer OS’es, installing old software can give problems because of a certain error 1607. Here’s how to solve the issue.


and here you can find the engine version 7

Posted by: joachimvandenbogaert | October 27, 2008

Start Menu Shortcuts Stopped Working

There is this annoying little problem in some windows distributions. Suddenly shortcuts stop working and you can only start up a program by double-clicking the executable in the Windows Explorer.

The following pages provide a solution:

Here’s a description of the problem:

and here’s how to get things working correctly again by using an Application, called ShellExView:

In my case the KDiff3 shell extension seemed to cause the problem. By disabling the extension I got my shortcuts back. I notified the development team.

Posted by: joachimvandenbogaert | September 19, 2008

Non virtual methods as a default in C#

The following article provides a nice insight into why C# methods are by default non-virtual.

I stumbled upon it by looking for a “final” keyword (as in Java). Having read the article it is clear why there is no such thing in C#.

Older Posts »