SocketTaskExtensions Class is not supported on .Net Framework 4.6.2
See original GitHub issueFTP Server OS: Windows
FTP Server Type: Windows Server IIS
Client Computer OS: Windows
FluentFTP Version: 4.2
Framework: .NET 4.6.2
.Net 4.6.2 does not support SocketTaskExtensions so it fails to compile.
The problem is in Streams\FtpSocketStream.cs
The following method fixes.
/// <summary>
/// Connect to the specified host
/// Detects timeout and throws that explicitly
/// </summary>
/// <param name="ipad">The ip address to connect to</param>
/// <param name="port">The port to connect to</param>
private async Task<bool> ConnectAsyncHelper(IPAddress ipad, int port, CancellationToken token) {
int ctmo = this.ConnectTimeout;
#if NETSTANDARD
try {
using (var timeoutSrc = CancellationTokenSource.CreateLinkedTokenSource(token)) {
timeoutSrc.CancelAfter(ctmo);
await EnableCancellation(m_socket.ConnectAsync(ipad, port), timeoutSrc.Token, () => DisposeSocket());
}
}
catch (SocketException ex) {
if (ex.SocketErrorCode == SocketError.OperationAborted ||
ex.SocketErrorCode == SocketError.TimedOut) {
throw new TimeoutException("Timed out trying to connect!");
}
throw;
}
#else
try {
#if v472
using (var timeoutSrc = CancellationTokenSource.CreateLinkedTokenSource(token)) {
timeoutSrc.CancelAfter(ctmo);
await EnableCancellation(m_socket.ConnectAsync(ipad, port), timeoutSrc.Token, () => DisposeSocket());
}
#else
using (var timeoutSrc = CancellationTokenSource.CreateLinkedTokenSource(token)) {
timeoutSrc.CancelAfter(ctmo);
var connectResult = m_socket.BeginConnect(ipad, port, null, null);
await EnableCancellation(Task.Factory.FromAsync(connectResult, m_socket.EndConnect), timeoutSrc.Token, () => DisposeSocket());
}
#endif
}
catch (SocketException ex) {
if (ex.SocketErrorCode == SocketError.OperationAborted ||
ex.SocketErrorCode == SocketError.TimedOut) {
throw new TimeoutException("Timed out trying to connect!");
}
throw;
}
catch (ObjectDisposedException ex) {
throw new TimeoutException("Timed out trying to connect!");
}
#endif
return m_socket.Connected;
}
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Can not add .NET framework 4.6.2 web app reference to . ...
I have created a .NET framework 4.6.2 web application. Then I have created a .NET Standard class library. The target framework is 1.6...
Read more >NET Standard issues on .NET Framework 4.7.1 #567
Summary Applications that target the .NET Framework 4.6.1 and use .NET Standard libraries may experience System.
Read more >Troubleshoot blocked .NET Framework installations and ...
Troubleshoot issues you encounter that prevent installation of the .NET Framework. Consult status messages for information to resolve ...
Read more >Troubleshoot .NET Framework targeting errors
To resolve the error, make sure that your application targets a .NET version that's compatible with the version that's targeted by the projects ......
Read more >Visual Studio doesn't recognize .NET Framework 4.6.2 is ...
I've installed .NET Framework 4.6.2 via the web installer, and everything looked good. However, after I restarted and opened up Visual ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@sandra-dcs Please see PR #1056.
Question: Do you believe a change to
MoveFile(...)
like yours, is an enhancement we should include?Released as V42.1.0