Can't Run Project.. Keeps Crashing

Sep 19, 2011 at 10:00 PM

Hi

I added System.Net.FtpClient to a .net 4.0 console application and I can compile it but everytime I try to run it crashes right away

 

System.IO.FileNotFoundException was unhandled
  Message=Could not load file or assembly 'System.Net.FtpClient, Version=1.0.4245.17535, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
  Source=ConsoleApplication7
  FileName=System.Net.FtpClient, Version=1.0.4245.17535, Culture=neutral, PublicKeyToken=null
  FusionLog==== Pre-bind state information ===
LOG: User =
LOG: DisplayName = System.Net.FtpClient, Version=1.0.4245.17535, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = ConsoleApplication7/ConsoleApplication7/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : ConsoleApplication7, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL ConsoleApplication7/ConsoleApplication7/bin/Debug/System.Net.FtpClient.DLL.
LOG: Attempting download of new URL ConsoleApplication7/ConsoleApplication7/bin/Debug/System.Net.FtpClient/System.Net.FtpClient.DLL.
LOG: Attempting download of new URL ConsoleApplication7/ConsoleApplication7/bin/Debug/System.Net.FtpClient.EXE.
LOG: Attempting download of new URL ConsoleApplication7/ConsoleApplication7/bin/Debug/System.Net.FtpClient/System.Net.FtpClient.EXE.

  StackTrace:
       at ConsoleApplication7.Program.Main(String[] args)
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Coordinator
Sep 19, 2011 at 10:08 PM
Edited Sep 19, 2011 at 10:09 PM

Hi,

If you're using Visual Studio, right click the System.Net.FtpClient reference, choose properties, and set the Copy Local property to true. If you're using some other IDE (or no IDE) just copy the DLL into the same directory as the exe you are producing.

J.P.

Sep 19, 2011 at 10:10 PM
Edited Sep 19, 2011 at 10:11 PM
jptrosclair wrote:

Hi,

If you're using Visual Studio, right click the System.Net.FtpClient reference, choose properties, and set the Copy Local property to true. If you're using some other IDE (or not) just copy the DLL into the same directory as the exe you are producing.

J.P.

I am using Vs 2010 Professional.

When I add it as a reference and look at the properties "Copy Local" is set to true. When I go to the console applications -> bin -> debug -> the .dll is already copied to that location.

Coordinator
Sep 19, 2011 at 10:16 PM

Well the exception states that it couldn't load the assembly because it could not find the file, Are you sure that the DLL is in the same folder as the executable? Is there possibly a security policy on the machine that disallows the executable to load DLL's in its working directory? You may right click on the DLL itself, go to properties and on the General Tab see if there is a button on the bottom that says "Unblock."

Sep 19, 2011 at 10:19 PM

ConsoleApplication1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe

ConsoleApplication1\ConsoleApplication1\bin\Debug\System.Net.FtpClient.NET4.dll

 

when I click on the above .dll and go to properties I don't see any "unblock" (I am using windows 7 64bit) . I don't have a problem with other .dll's and not aware of any security policy that was set. I am not sure how I could check that.

Coordinator
Sep 19, 2011 at 10:23 PM

Rename System.Net.FtpClient.NET4.dll to System.Net.FtpClient.dll. Your exception indicates the file name is wrong.

Sep 19, 2011 at 10:25 PM
jptrosclair wrote:

Rename System.Net.FtpClient.NET4.dll to System.Net.FtpClient.dll. Your exception indicates the file name is wrong.

Ok

I think that is the problem.

Thanks

Coordinator
Sep 19, 2011 at 10:27 PM

No problem