I am trying to use the WinSCP within my C# project for some ftp automation. I am using Visual Studio 2012 and am unsure on how to get it to work.
Things I have done so far:
- I copied the
WinSCP.exe
into my project folder. - I imported a reference to the
WinSCPnet.dll
into my project - I ran
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe Path/To/WINSCPnet.DLL /codebase /tlb
This is my code as of now:
using WinSCP;
static void Main(string[] args)
{
try
{
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "hostname.address.com",
UserName = "Username",
Password = "Password"
};
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
}
}
When I run this in code I get the following exception:
Could not load file or assembly 'WinSCP, Version=1.0.7.3446, Culture=neutral,
PublicKeyToken=b5f19f5762436b89' or one of its dependencies. The module was expected to
contain an assembly manifest.
And Visual Studio's error is: BadImageFormatException was unhandled.
I am not exactly sure how to import WinSCP into my C# program and would appreciate some guidance here.
Conclusion I was using 5.2.5 Beta and 32bit but my project was 64 bit