Category Archives: Coding

Login failed for user ‘IIS APPPOOL\DefaultAppPool’

This error has had me running round all the houses today, it was so annoying.

You need to set the Identity that IIS is using to that of Network Service.

Many thanks to zillionics. for pointing out that not only does your webapp have to have it’s app pool Identity set to Network Service but so does the DefaultAppPool (I guess there was a clue there in the error message!)

Here’s a link to their post: login-failed-for-user-iis-apppooldefaultapppool

In case you are having MSSQLServer issues here is a link on how to set the the permissions to allow the Network Service have access to your database:
/login-failed-for-user-networkservice

svn merge a revision on trunk to a branch

Merging a set of files from Trunk to a branch

The scenario is that you have made changes to a selection of files and committed them all in one revision.  You then wish to merge only these changes into a branch (e.g. for release).  How can you grab just your changes and merge these?

  1. Find the revision number on trunk that you want to merge into the branch
  2. Check out the branch to your local machine
  3. cd to the branch directory on your machine
  4. make the call: svn merge -c [revision_number] [trunk directory]
  5. svn merge -c 896929 ../trunk

-c gets the differences between the files in the revision you specify and the one before.  It will then try to merge these changes into the branch.

You can use the –dry-run switch to preview the outcome before going ahead with the merge.

Nunit cannot find nunit-console-runner

Sigh!

After all yesterday’s work, I came back in this morning to find that yes – hoorah, the project had built successfully on the build server.

But oh no! It no longer built on my machine!  Not surprising I guess as I spent so much time trying so many things.

The error I got was:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'nunit-console-runner, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The system cannot find the file specified.

File name: 'nunit-console-runner, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' at NUnit.ConsoleRunner.Class1.Main(String[] args)

Retracing my steps I found that I had modified the nunit-console.exe.config (found in the nunit \bin\net-2.0 directory).

I had added a supportedRuntime tag:

  </startup><supportedRuntime version="v2.0.50727"/></startup>

I removed this and everything is hunky dory again.
If you are getting this error then take a look at that setting. I hope that helps.

NPanday nunit BadImageFormatException

Having got maven to build my C# project including unit tests on my developer machine, I was disheartened to be thwarted by a new lot of errors on the build server.

I took over this project from another developer and so was not certain what the state server configuration was in.

nunit executable in the PATH

The first hurdle was realising that the nunit executable must have it’s location included in the server’s PATH environment variable.

HOORAH, I thought.  Now I can move on.

Yeah right!

BadImageFormatException

The unit tests still wouldn’t build.  The next error was

ProcessModel: Default DomainUsage: Single
Execution Runtime: Default
Unhandled Exception:
System.BadImageFormatException: Could not load file or assembly 'BBCNewsI.MPS.Tests, Version=2.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'BBCNewsI.MPS.Tests, Version=2.2.3.0, Culture=neutral, PublicKeyToken=null'

😥

Why couldn’t maven see my test project??  I can see it!  After looking in a lot of wrong places I found the answer.  Nunit was running the tests as 64 bit because the build server is 64 bit.  As the code is dot net 2.0 and built as 32 bit, this is not good.

Maven pom.xml file

Again I looked in the wrong place.  The fix for this is not in nunit but in your maven pom file.  You need to force the tests to be run as 32 bit by adding this parameter:

forceX86

So here is how to describe your test.  In your pom file, add the parameter to the maven-test-plugin:

<plugin>
<groupId>org.apache.npanday.plugins</groupId>
<artifactId>maven-test-plugin</artifactId>
<version>1.4.0-incubating</version>
<configuration>
<forceX86>true</forceX86>
<integrationTest>true</integrationTest>
</configuration>
</plugin>

Ignoring files in subversion

Often you find that you have files that are part of your project that do not belong in version control and you just don’t want to be bugged by subversion highlighting the fact that you haven’t checked them in.

There is documentation on how to ignore these files in the svn book but I found that it lacked a small detail.

Ignoring files globally

There are some files you know that you will never want to check into the repository no matter what project you are working on.  Rather than having to mark them to be ignored in every directory of every project that you store in the repo you can instead set a global ignore.

In your subverison client install directory (for unix operation systems it is probably called .subversion) there is a file called config, scroll down to the section marked global-ignores and set the patterns you wish to ignore

global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
*.rej *~ #*# .#* .*.swp .DS_Store .classpath .settings .project

As you can see, you can use regex to define each pattern. Each pattern is separated by a whitespace.

Setting ignore on a specific directory

N.B. You cannot ignore individual files, you can only set patterns to ignore in a given directory.
First navigate to that directory and issue this command:

svn propedit svn:ignore .

After this you will be presented with a file in which you should type in your pattern(s) to ignore.
It’s pretty simple but I just didn’t spot the fact that you should be putting the patterns in this file rather than specifying the pattern in the svn propedit command itself.

Don’t forget to commit your changes!
Happy ignoring!

Eclipse Package Explorer

Eclipse Indigo

Have you ever had the irritating scenario where all your Java folders (including the empty ones) appear in Package Explorer even though you have correctly created the build path?

I was getting rather irritated by this intermittent “feature” so I asked a friend!

The simple solution is to filter out the unwanted empty folders.

  • Click on the downwards arrow in the top right hand side of the Package Explorer window
  • Select Filters and then make sure that “Empty Packages” is ticked

Now you will see a much cleaner representation of your project in Package Explorer