views:

96

answers:

3

I have some c# code that downloads files from an FTP server. It works fine when I run it and it works fine when I install it on my development machine then run it. However, when I try to install it on another machine (a Windows XP SP3 VM) it doesn't work. No exceptions are thrown or anything.

Here is the short version of my code:

reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + dir + "/"));
reqFTP.BeginGetResponse(new AsyncCallback(DLFilesInDirCallback), state);

.......

public void DLFilesInDirCallback(IAsyncResult ar)
{
   MessageBox.Show("dcallbk");
   ..... }

The message box never comes up when I run the installed version on another computer. Is there a missing dependency or something I need to install before it can be run on another machine? .net framework 4 is already installed on the xp machine. I tried turning my firewall off, and tried synchronous ftp with the same result.

Thanks, Matt

+1  A: 

Try to use synchronous method for testing purpose or use EndGetResponse method to get an exception. BeginGetResponse wouldn't throw the exception on it's own.

I do call EndGetResponse, it is just after the message box code which never gets called. response = (FtpWebResponse)state.Request.EndGetResponse(ar);
I tried using the synchronous getresponse and it works fine on my machine but just hangs when installed on another machine.
It does throw a System.Net.WebException: the operation has timed out, after 2 - 2.5 minutes
+1  A: 

Sounds Like a network issue or User rights error. Check the systems event log when you run the application the error could be hidden from you. On the local machine try using windows explorer to ftp a text file using the same URI that your program uses. You may need to elevate the users accesss or run your app as admin.

Aaron
as stated above i have tried the ftp in firefox
+2  A: 

Try using .NET Reflector to look at your executable. You should be able to see what dependencies it has using that.

Antony Scott
Interesting, System.Net doesn't seem to be included in the References when I run .NET reflector.
I'm not sure if it is supposed to be there or not.
I don't ever recall it being a standard reference. I've only ever used it once or twice and I think I had to add it in there
Antony Scott