As I recently worked on a private project, where I had to compare several files with each other, I also came across the integrated "Diff" method of SVN. To compare two files, you can call the SVN with the following command:

svn diff -r OLD_REVISION:NEW_REVISION FILE

and you get instantly your output in the diff-format.

 

To call SVN I wanted to start the process from an ASP.Net class in the background and capture the output. Unfortunately I got a problem. The output seemed to be empty all the time.

As I tried the same thing some days later, I suddenly got the desired output. When I came home, I replaced my old code with the new one, but again the output remained silent. Because of this I started to compare both applications (my test app and the app for the file comparison). At first I thought Vista would suppress the output, because the PC on my workplace has XP installed on it, while my private PC has Vista, but this seemed to be the wrong reason, because it also didn't work as I executed the testapp from my "work"-PC on my private one... But that was the moment I recognized it. The difference was the application type: While my project itself was a web application, the test project was a Consolen application.

This is the code I used: 

 

ProcessStartInfo ps = new ProcessStartInfo("svn", "diff -r 4:6 file:///MY_LOCAL_FILE");
ps.UseShellExecute = false;
ps.RedirectStandardOutput = true;

Process p = new Process();
p.StartInfo = ps;
p.Start();
p.WaitForExit();

string output = p.StandardOutput.ReadToEnd();

 

The string "output" was always empty (not null), while the console application showed the right output:

 

Console:

image

Web application:

image

 

That problem I had to solve, because I didn't want to use a desktop application. So I tried several things. At first I thought there would be problems with the TrustLevel of the application and that the web application was more restrictive, but no matter which changes I made at the security settings, there was no change, until I found a code snippet, which I copied 1:1. It worked in the web application, but when I reduced the copied code to the needed parts by removing the "senseless" stuff, it didn't work again... So I took the code from the internet and removed line-by-line to find out which of the lines made the clue - in this way I found the reason:

The magic property was "RedirectStandardError". As soon as I changed its value to "true", everything worked fine:

image

 

HINT:  

As I started to write this blog entry, I first wanted to use another application than SVN, so I chose "PING" (because it's available everywhere). Interestingly it worked without any problems:

image

So obviously it depends also on the type of the called application, if you have to change the property or if it works also without.