tags:

views:

571

answers:

8

My program run fine from anywhere else on my drive apart from the Program Files directory (windows XP), I am logged on as administrator so I have full permissions to the drive. It runs fine from the root of c: the windows directory basically anywhere else apart from Program Files. I have recreated this problem on 4 different machines 2 XP, 2 Vista.

My program is a C# .Net 2.0 program. What on earth could the problem be?

I have even copied my entire project to the Program Files directory and I can't debug it from there it just won't run up, no errors at all.

Thanks for any help.

+2  A: 

Just guessing, but if your program tries to save data to the program-directory, Vista will prevent this and change the path dynamically to something like c:\users[user]\AppData. Maybe this gives you a hint on whats going on.

Otherwise we need more info on your program to help you.

BeowulfOF
He has this problem in 2 machines with XP.
Daok
A: 

Hi,

The program does run from other folders with a space in the path such as Documents and Settings, the program does create a temporary file in the user profile\appdata folder.

If I run the app several time from somewhere it will run from I've just noticed I get an error with the option to debug but VS won't show me the location of the problem I just get the error belo.

Unhandled exception at 0x79fb96a2 in test.exe: 0xC0000005: Access violation reading location 0x0000000c.

The problem can be recreated on XP and Vista.

Many thanks

Please add the extra information to the question.
Gamecat
Put the .PDB file in the same directory. You should get better information.
Brad Bruce
+2  A: 

If you can't debug, you can always create a debug log. It is a bit slow, but in the end you will find the place where the program stops working.

LogDebug('before 1');
Statement1;
LogDebug('before 2');
Statement2;
LogDebug('before 3');
Statement3;
LogDebug('after 3');
Gamecat
Mmm... crash diagnosis in non-debuggable code. Funtimes!
xan
A: 

If this is a machine managed by your company's "big brother", it sounds like only "allowed" applications can run from "Program files"

Brad Bruce
+1  A: 

I've tried the program on a fresh XP install that doesn't have any orgranizational policies applied.

:-(

Ouch! Have you tried with the .PDB file in the same directory yet?
Brad Bruce
Yes and it didn't make any difference, I also set the debug location to the program files folder and it won't run, change it to anywhere else and it runs fine. I'm puzzled.
Maybe some of the information at http://www.codeproject.com/KB/debug/postmortemdebug_standalone1.aspx can help you pinpoint where the error is.
Brad Bruce
A: 

What does your programm read in its directory?

Why are you creating a temp file in user/appdata? For temporary files, you should use the API to get the temporary folder for the current profile and ideally an temporary filename, works like this:

string tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());

To help you properly, we need to know what your program should do on init.

BeowulfOF
A: 

Have you got any thing like Anti-virus software running?

Which is it?

  • Is it not running (probably OS related)
  • OR is it falling over (probably permissions)
  • OR running and not producing expected output? (probably permissions)

Have you checked the Event Logs?

Try calling it from a batch file and see what happens.

uhmm anyone want to try his .exe on their machine??

DrG
A: 

Sorry about this but I found the problem, I had some crap code that was looking for arguments being passed including 'file' and the file in 'program files' was forcing the program into a command line mode that has no gui. Really sorry to have wasted your time on such a trivial problem, you live and learn!

Thanks to all.