Fix - just ignore it
I had the same problem in my .NET Framework app and I found out that I can... just ignore that exception and click continue in debug -> goes further and session is opened.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Hi,
This is happening when I am trying to compile VS 2013 solution
System.TypeInitializationException was unhandled
Message: An unhandled exception of type 'System.TypeInitializationException' occurred in mscorlib.dll
Additional information: The type initializer for 'XXXXX' threw an exception.
I have sent you an email.
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
Additional information: The process cannot access the file 'C:\Users\Admin\AppData\Local\Temp\wscp24C0.0223CC89.tmp' because it is being used by another process.
private bool uploadFile(string path, string hostName, string username, string password)
{
try
{
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = hostName,
UserName = username,
Password = password,
SshHostKeyFingerprint = "ssh-rsa 1024 **:**:**:**:20:8f:95:69:12:f5:52:**:**:**:**:**"
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(path, "/", false, transferOptions);
// Throw on any error
transferResult.Check();
// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}
return true;
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
return false;
}
}