views:

47

answers:

1

HI,

I've created a batch file called post-commit.bat and placed it under the /hooks directory.

The content of the file is:

TestCS.exe

The content of the exe file is:

static void Main(string[] args)
    {

        try
        {
            // create a writer and open the file
            TextWriter tw = new StreamWriter("date.txt");

            // write a line of text to the file
            tw.WriteLine(DateTime.Now);

            // close the stream
            tw.Close();
        }
        catch { }
    }

When I double-click on post-commit.bat, it creates the date.txt file.

When I commit in SVN, it takes time, and eventually gives me the following message: alt text

What can be the problem?

Thanks!

+1  A: 

The obvious thing to do would be to launch the debugger and get a better idea of where the problem is occurring.

I would suggest that you should use a using statement for your TextWriter, and avoid catching and swallowing all exceptions without any attempt to even log the error.

Is that really your whole code? You're not using args at all? It's hard to see how that code would lead to an IndexOutOfRangeException...

Jon Skeet
I've tried the using statement, still the same. Even deleted the string args[]. Still the same.
Oded
I figured it out.When running the testCS.exe, it apparently looked for the file in /SVNServer/bin and not in the hooks folder. In the bin folder I had a testCS.exe file with IndexOutOfRangeException.Thanks.
Oded
I nearly mentioned "are you sure you're running the binary you think you're running" but didn't bother in the end. Oops.
Jon Skeet